WindowEventHandlers mixin describes the event handlers common to several interfaces like Window, or HTMLBodyElement and  HTMLFrameSetElement. Each of these interfaces can implement additional specific event handlers.

Note: WindowEventHandlers is a mixin and not an interface; you can't actually create an object of type WindowEventHandlers.

Properties

The events properties, of the form onXYZ, are defined on the WindowEventHandlers, and implemented by Window, and WorkerGlobalScope for Web Workers.

WindowEventHandlers.onafterprint
Is an EventHandler representing the code to be called when the afterprint event is raised.
WindowEventHandlers.onbeforeprint
Is an EventHandler representing the code to be called when the beforeprint event is raised.
WindowEventHandlers.onbeforeunload
Is an EventHandler representing the code to be called when the beforeunload event is raised.
WindowEventHandlers.onhashchange
Is an EventHandler representing the code to be called when the hashchange event is raised.
WindowEventHandlers.onlanguagechange
Is an EventHandler representing the code to be called when the languagechange event is raised.
WindowEventHandlers.onmessage
Is an EventHandler representing the code to be called when the message event is raised.
WindowEventHandlers.onmessageerror
Is an EventHandler representing the code to be called when the MessageError event is raised.
WindowEventHandlers.onoffline
Is an EventHandler representing the code to be called when the offline event is raised.
WindowEventHandlers.ononline
Is an EventHandler representing the code to be called when the online event is raised.
WindowEventHandlers.onpagehide
Is an EventHandler representing the code to be called when the pagehide event is raised.
WindowEventHandlers.onpageshow
Is an EventHandler representing the code to be called when the pageshow event is raised.
WindowEventHandlers.onpopstate
Is an EventHandler representing the code to be called when the popstate event is raised.
WindowEventHandlers.onstorage
Is an EventHandler representing the code to be called when the storage event is raised.
WindowEventHandlers.onunhandledrejection
An event handler for unhandled Promise rejection events.
WindowEventHandlers.onunload
Is an EventHandler representing the code to be called when the unload event is raised.

Methods

This interface defines no method.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'GlobalEventHandlers' in that specification.
Living Standard No change since the latest snapshot, HTML 5.1.
HTML 5.1
The definition of 'GlobalEventHandlers' in that specification.
Recommendation Snapshot of HTML Living Standard. Added onlanguage since the HTML5 snapshot.
HTML5
The definition of 'GlobalEventHandlers' in that specification.
Recommendation Snapshot of HTML Living Standard. Creation of WindowEventHandlers (properties where on the target before it).

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes ? Yes ? Yes ?
onafterprint63 Yes6 Yes No No
onbeforeprint63 Yes6 Yes No No
onbeforeunload1 Yes14123
onhashchange5 Yes3.68105
onlanguagechange37 ?32 No24 ?
onmessage60 ? ? ?47 ?
onmessageerror60 ?57 ?47 ?
onpopstate ? ? ? ? ? ?
onrejectionhandled49 ? No2 No No No
onstorage ? Yes45 ? ? ?
onunhandledrejection49 Yes No2 No No No
onunload Yes Yes Yes Yes Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes ? Yes Yes ? ?
onafterprint Yes Yes Yes ? No ? ?
onbeforeprint Yes Yes Yes ? No ? ?
onbeforeunload Yes Yes Yes ? Yes No1 ?
onhashchange Yes Yes Yes4115 ?
onlanguagechange3737 ?424 ? ?
onmessage6060 ? ?47 ? ?
onmessageerror6060 ?5747 ? ?
onpopstate ? ? ? ? ? ? ?
onrejectionhandled No No ? No2 No No ?
onstorage No No Yes45 ? ? ?
onunhandledrejection No No Yes No2 No No ?
onunload Yes Yes Yes Yes Yes Yes ?

1. Implementation seems defect.

2. Firefox implements the PromiseRejectionEvent interface if you go to about:config and set the dom.promise_rejection_events.enabled pref to true. However, Firefox doesn't yet actually send the unhandledrejection or understand rejectionhandled events. Completing the implementation will be addressed in bug 1362272.

See also

Document Tags and Contributors

Contributors to this page: fscholz, chrisdavidmills, jpmedley, teoli, Ehsan
Last updated by: fscholz,