Home > Article > Web Front-end > Javascript event capture memo (setCapture, captureEvents)_javascript skills
During this period of time, I have been studying Js drag and drop issues for QZone. Today I suddenly discovered that live.com's module drag and drop can actually be used across the browser. What is the method that allows the mousemove and mouseup events to be triggered outside the browser, so I down-analyzed the entire live js, and found that it was a small function doing "strange things".
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()
Mozilla also has a similar function, the method is slightly different
window.captureEvents(Event.eventType)
window.releaseEvents(Event.eventType)
Event is a special object of Mozilla.
eventType includes: Abort, Blur, Click, Change, DblClick, DragDrop, Error, Focus, KeyDown, KeyPress, KeyUp , Load, MouseDown
The following example is lazy and not compatible with Mozilla, just for demonstration