However, setCapture does not support keyboard events and can only capture the following mouse events: onmousedown, onmouseup, onmousemove, onclick, ondblclick, onmouseover and onmouseout.
The main purpose of the program is to capture the onmousemove and onmouseup events.
The msdn introduction also mentioned that setCapture has a bool parameter, which is used to set whether all mouse events in the container are captured by the container.
When the parameter is true (default), the container will capture mouse events for all objects in the container, that is, objects within the container will not trigger mouse events (the same as objects outside the container);
When the parameter is false, the container will not Capture mouse events of objects within the container, that is, objects within the container can trigger events and cancel bubbling normally.
Object.setCapture() When an object is setCapture, its method will be inherited to the entire document for capture. When you do not need to inherit the method to capture the entire document, use object.releaseCapture() to release.
Mozilla also has a similar function, with a slightly different method
window.captureEvents(Event.eventType)
window. releaseEvents(Event.eventType)
Example: