WindowEventHandlers

The 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.onrejectionhandled
Is an EventHandler representing the code to be called when the rejectionhandled event is raised, indicating that a Promise was rejected and the rejection has been handled.
WindowEventHandlers.onstorage
Is an EventHandler representing the code to be called when the storage event is raised.
WindowEventHandlers.onunhandledrejection
Is an EventHandler representing the code to be called when the unhandledrejection event is raised, indicating that a Promise was rejected but the rejection was not handled.
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 'WindowEventHandlers' in that specification.
Living Standard No change since the latest snapshot, HTML 5.1.
HTML 5.1
The definition of 'WindowEventHandlers' in that specification.
Recommendation Snapshot of HTML Living Standard. Added onlanguage since the HTML5 snapshot.
HTML5
The definition of 'WindowEventHandlers' in that specification.
Recommendation Snapshot of HTML Living Standard. Creation of WindowEventHandlers (properties where on the target before it).

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
WindowEventHandlersChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
onafterprintChrome Full support 63Edge Full support YesFirefox Full support 6IE Full support YesOpera Full support 50Safari No support NoWebView Android Full support 63Chrome Android Full support 63Firefox Android ? Opera Android Full support 46Safari iOS ? Samsung Internet Android ?
onbeforeprintChrome Full support 63Edge Full support YesFirefox Full support 6IE Full support YesOpera Full support 50Safari No support NoWebView Android Full support 63Chrome Android Full support 63Firefox Android ? Opera Android Full support 46Safari iOS ? Samsung Internet Android ?
onbeforeunloadChrome Full support 1Edge Full support YesFirefox Full support 1IE Full support 4Opera Full support 12Safari Full support 3WebView Android Full support YesChrome Android Full support YesFirefox Android ? Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
onhashchangeChrome Full support 5Edge Full support YesFirefox Full support 3.6IE Full support 8Opera Full support 10Safari Full support 5WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 5Samsung Internet Android ?
onlanguagechange
Experimental
Chrome Full support 37Edge ? Firefox Full support 32IE No support NoOpera Full support 24Safari ? WebView Android Full support 37Chrome Android Full support 37Firefox Android Full support 4Opera Android Full support 24Safari iOS ? Samsung Internet Android ?
onmessageChrome Full support 60Edge ? Firefox ? IE ? Opera Full support 47Safari ? WebView Android Full support 60Chrome Android Full support 60Firefox Android ? Opera Android Full support 44Safari iOS ? Samsung Internet Android ?
onmessageerrorChrome Full support 60Edge ? Firefox Full support 57IE ? Opera Full support 47Safari ? WebView Android Full support 60Chrome Android Full support 60Firefox Android Full support 57Opera Android Full support 44Safari iOS ? Samsung Internet Android ?
onpopstateChrome Full support 5Edge Full support 12Firefox Full support 4IE Full support 10Opera Full support 11.5Safari Full support 6WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11.5Safari iOS Full support 5.1Samsung Internet Android ?
onrejectionhandledChrome Full support 49Edge ? Firefox Full support 69
Full support 69
Full support 68
Disabled
Disabled From version 68: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Partial support 55
Notes Disabled
Notes This event handler was added in Firefox 55 but was disabled since it wasn't fully implemented. It was fully implemented in Firefox 68 and enabled by default in Firefox 69.
Disabled From version 55: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 36Safari Full support 11WebView Android Full support 49Chrome Android Full support 49Firefox Android Full support 68
Disabled
Full support 68
Disabled
Disabled From version 68: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Partial support 55
Notes Disabled
Notes This event handler was added in Firefox 55 but was disabled since it wasn't fully implemented. It was fully implemented in Firefox 68 but not enabled by default.
Disabled From version 55: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android No support NoSafari iOS Full support 11.3Samsung Internet Android ?
onstorageChrome Full support 1Edge Full support YesFirefox Full support 45IE ? Opera Full support 15Safari ? WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 45Opera Android Full support 14Safari iOS ? Samsung Internet Android ?
onunhandledrejectionChrome Full support 49Edge ? Firefox Full support 69
Full support 69
Full support 68
Disabled
Disabled From version 68: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Partial support 55
Notes Disabled
Notes This event handler was added in Firefox 55 but was disabled since it wasn't fully implemented. It was fully implemented in Firefox 68 and enabled by default in Firefox 69.
Disabled From version 55: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 36Safari Full support 11WebView Android Full support 49Chrome Android Full support 49Firefox Android Full support 68
Disabled
Full support 68
Disabled
Disabled From version 68: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Partial support 55
Notes Disabled
Notes This event handler was added in Firefox 55 but was disabled since it wasn't fully implemented. It was fully implemented in Firefox 68 but not enabled by default.
Disabled From version 55: this feature is behind the dom.promise_rejection_events.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android No support NoSafari iOS Full support 11.3Samsung Internet Android ?
onunloadChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also