SetCapture is used to capture mouse events to the specified objects in the current document. This object receives all mouse events for the current application or the entire system. However, setCapture does not support Keyboard Events. Only the following mouse events can be captured: onmousedown, onmouseup, onmousemove, onclick, ondblclick, onmouseover, and onmouseout.
The program mainly needs to capture onmousemove and onmouseup events.
In the msdn introduction, it is also said that setCapture has a bool parameter to set whether all mouse events in the container are captured by the container.
When the parameter is true (default), the container will capture the mouse events of all objects in the container, that is, the objects in the container will not trigger the mouse events (the same as the objects outside the container );
When the parameter is set to false, the container does not capture the mouse events of objects in the container. That is, objects in the container can trigger events normally and cancel bubbles.
Object. setCapture () when an object is setCapture, its methods will be inherited to the entire document for capture. Objects. releaseCapture () must be used to release methods that do not need to inherit from the entire document for capturing.
Mozilla also has similar functions, with slightly different methods
Window. captureEvents (Event. eventType)
Window. releaseEvents (Event. eventType)
Example:
The Code is as follows:
Click the IE menu or button to see it :)
Or outside the IE window