--- title: GlobalEventHandlers slug: Web/API/GlobalEventHandlers translation_of: Web/API/GlobalEventHandlers ---
GlobalEventHandlers(通用事件處理器)
在多個介面,如 {{domxref("HTMLElement")}}、{{domxref("Document")}} 和 {{domxref("Window")}} 當中加入了共有的事件處理器屬性,這些介面皆能夠加入除了以下清單外的更多事件處理器。
Note: GlobalEventHandlers
is a mixin and not an interface; you can't actually create an object of type GlobalEventHandlers
.
This interface doesn't include any properties except for the event handlers listed below.
These event handlers are defined on the {{domxref("GlobalEventHandlers")}} mixin, and implemented by {{domxref("HTMLElement")}}, {{domxref("Document")}}, {{domxref("Window")}}, as well as by {{domxref("WorkerGlobalScope")}} for Web Workers.
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("gotpointercapture")}} event type is raised.
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("lostpointercapture")}} event type is raised.
This interface defines no methods.
Specification | Status | Comment |
---|---|---|
{{SpecName("Selection API",'', 'Extension to GlobalEventHandlers')}} | {{Spec2('Selection API')}} | Adds onselectionchange. |
{{SpecName('Pointer Lock', '#extensions-to-the-document-interface', 'Extension of Document')}} | {{Spec2('Pointer Lock')}} | Adds onpointerlockchange and onpointerlockerror on {{domxref("Document")}}. It is experimentally implemented on GlobalEventHandlers . |
{{SpecName('HTML WHATWG', '#globaleventhandlers', 'GlobalEventHandlers')}} | {{Spec2('HTML WHATWG')}} | No change since the latest snapshot, {{SpecName("HTML5.1")}}. |
{{SpecName('HTML5.1', '#globaleventhandlers', 'GlobalEventHandlers')}} | {{Spec2('HTML5.1')}} | Snapshot of {{SpecName("HTML WHATWG")}}. Added onsort since the {{SpecName("HTML5 W3C")}} snapshot. |
{{SpecName("HTML5 W3C", "#globaleventhandlers", "GlobalEventHandlers")}} | {{Spec2('HTML5 W3C')}} | Snapshot of {{SpecName("HTML WHATWG")}}. Creation of GlobalEventHandlers (properties where on the target before it). |
{{CompatibilityTable}}
Feature | Firefox (Gecko) | Chrome | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
oncanplay , oncanplaythrough , ondurationchange , onemptied , onended , onloadeddata , onloadedmetadata , onloadstart , onpause , onplay , onplaying , onprogress , onratechange , onseeked , onseeking , onstalled , ontimeupdate , onvolumechange , onwaiting |
{{CompatGeckoDesktop(1.9.1)}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
onsuspend |
{{CompatGeckoDesktop(1.9.2)}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
ondrag , ondragend , ondragenter , ondragleave , ondragover , ondragstart , ondrop |
{{CompatGeckoDesktop(1.9.1)}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
onmouseenter , onmouseleave |
{{CompatGeckoDesktop(10)}} | {{CompatChrome(30.0)}} | {{CompatUnknown}} | 5.5 | 17 | {{CompatUnknown}} |
ondragexit |
{{CompatNo}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
oncancel |
{{CompatNo}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
onclose |
{{CompatNo}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
oncuechange |
{{CompatNo}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
onmousewheel |
{{CompatNo}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
onsort {{experimental_inline}} |
{{CompatNo}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
onmozfullscreenchange , onmozfullscreenerror {{non-standard_inline}} |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} {{property_prefix("-webkit")}} {{CompatVersionUnknown}} (unprefixed) |
{{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
onpointerlockchange , onpointerlockerror |
{{CompatGeckoDesktop(10)}}[1] | {{CompatVersionUnknown}}[2] {{property_prefix("-webkit")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
onpointercancel , onpointerdown , onpointerup , onpointermove , onpointerout , onpointerover , onpointerenter , onpointerleave |
{{CompatVersionUnknown}}[3] | {{CompatChrome(55.0)}} | {{CompatVersionUnknown}} | 10 | {{CompatUnknown}} | {{CompatUnknown}} |
onselectionchange |
{{CompatGeckoDesktop(43)}}[4] | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
ontouchend , ontouchcancel , ontouchmove , ontouchstart |
{{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
animationstart , animationend , animationcancel , animationiteration |
{{CompatGeckoDesktop(51)}} | {{CompatVersionUnknown}} {{property_prefix("-webkit")}} {{CompatVersionUnknown}} (unprefixed) |
{{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
ongotpointercapture , onlostpointercapture |
{{CompatUnknown}} | {{CompatChrome(57.0)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOpera(44)}} | {{CompatUnknown}} |
onauxclick |
{{CompatGeckoDesktop(53)}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android Webview | Edge | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
ondrag , ondragend , ondragenter , ondragleave , ondragover , ondragstart , ondrop |
{{CompatUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile(1.9.1)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
oncanplay , oncanplaythrough , ondurationchange , onemptied , onended , onloadeddata , onloadedmetadata , onloadstart , onpause , onplay , onplaying , onprogress , onratechange , onseeked , onseeking , onstalled , ontimeupdate , onvolumechange , onwaiting |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile(1.9.1)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
onmouseenter , onmouseleave |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile(10)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
onsuspend |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile(1.9.2)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
ondragexit |
{{CompatNo}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} |
oncancel |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
onclose |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
oncuechange |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
onmousewheel |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
onsort |
{{CompatNo}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} |
onmozfullscreenchange , onmozfullscreenerror {{non-standard_inline}} |
{{CompatVersionUnknown}} {{property_prefix("-webkit")}} {{CompatVersionUnknown}} (unprefixed) |
{{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatVersionUnknown}} {{property_prefix("-webkit")}} {{CompatVersionUnknown}} (unprefixed) |
onpointerlockchange , onpointerlockerror |
{{CompatNo}} | {{CompatUnknown}} | {{CompatGeckoMobile(10)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} |
onpointercancel , onpointerdown , onpointerup , onpointermove , onpointerout , onpointerover , onpointerenter , onpointerleave |
{{CompatChrome(55.0)}} | {{CompatUnknown}} | {{CompatVersionUnknown}}[3] | {{CompatNo}} | 10 | {{CompatNo}} | {{CompatNo}} | {{CompatChrome(55.0)}} |
onselectionchange |
{{CompatNo}} | {{CompatUnknown}} | {{CompatGeckoMobile(43)}}[4] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} |
ontouchend , ontouchcancel , ontouchmove , ontouchstart |
{{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
animationstart , animationend , animationcancel , animationiteration |
{{CompatVersionUnknown}} {{property_prefix("-webkit")}} {{CompatVersionUnknown}} (unprefixed) |
{{CompatUnknown}} | {{CompatGeckoMobile(51)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} {{property_prefix("-webkit")}} {{CompatVersionUnknown}} (unprefixed) |
ongotpointercapture , onlostpointercapture |
{{CompatChrome(57.0)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOperaMobile(44)}} | {{CompatUnknown}} | {{CompatChrome(57.0)}} |
onauxclick |
{{CompatVersionUnknown}} | {{CompatNo}} | {{CompatGeckoMobile(53)}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatVersionUnknown}} |
[1] In Gecko this is implemented as onmozpointerlockchange
, onmozpointerlockerror
.
[2] In Blink this is implemented as onwebkitpointerlockchange
, onwebkitpointerlockerror
.
[3] This is implemented behind the dom.w3c_pointer_events.enabled
preference, defaulting to false
.
[4] This is implemented behind the dom.select_events.enabled
preference, that default to false
, except on Nightly.