Home  >  Article  >  Web Front-end  >  Javascript event capture memo (setCapture, captureEvents)_javascript skills

Javascript event capture memo (setCapture, captureEvents)_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:26:211095browse

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


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]
Related links:
For IE
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/setcapture .asp
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/releasecapture.asp

For Mozilla
http://developer.mozilla.org/en/docs/DOM:window.captureEvents
http://developer. mozilla.org/en/docs/DOM:window.releaseEvents
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn