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
.
The events properties, of the form onXYZ
, are defined on the WindowEventHandlers
, and implemented by Window
, and WorkerGlobalScope
for Web Workers.
WindowEventHandlers.onafterprint
EventHandler
representing the code to be called when the afterprint
event is raised.WindowEventHandlers.onbeforeprint
EventHandler
representing the code to be called when the beforeprint
event is raised.WindowEventHandlers.onbeforeunload
EventHandler
representing the code to be called when the beforeunload
event is raised.WindowEventHandlers.onhashchange
EventHandler
representing the code to be called when the hashchange
event is raised.WindowEventHandlers.onlanguagechange
EventHandler
representing the code to be called when the languagechange
event is raised.WindowEventHandlers.onmessage
EventHandler
representing the code to be called when the message
event is raised.WindowEventHandlers.onmessageerror
EventHandler
representing the code to be called when the MessageError
event is raised.WindowEventHandlers.onoffline
EventHandler
representing the code to be called when the offline
event is raised.WindowEventHandlers.ononline
EventHandler
representing the code to be called when the online
event is raised.WindowEventHandlers.onpagehide
EventHandler
representing the code to be called when the pagehide
event is raised.WindowEventHandlers.onpageshow
EventHandler
representing the code to be called when the pageshow
event is raised.WindowEventHandlers.onpopstate
EventHandler
representing the code to be called when the popstate
event is raised.WindowEventHandlers.onstorage
EventHandler
representing the code to be called when the storage
event is raised.WindowEventHandlers.onunhandledrejection
Promise
rejection events.WindowEventHandlers.onunload
EventHandler
representing the code to be called when the unload
event is raised.This interface defines no method.
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). |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | ? | Yes | ? | Yes | ? |
onafterprint |
63 | Yes | 6 | Yes | 50 | No |
onbeforeprint |
63 | Yes | 6 | Yes | 50 | No |
onbeforeunload |
1 | Yes | 1 | 4 | 12 | 3 |
onhashchange |
5 | Yes | 3.6 | 8 | 10 | 5 |
onlanguagechange
|
37 | ? | 32 | No | 24 | ? |
onmessage |
60 | ? | ? | ? | 47 | ? |
onmessageerror |
60 | ? | 57 | ? | 47 | ? |
onpopstate |
5 | 12 | 4 | 10 | 11.5 | 6 |
onrejectionhandled |
49 | ? | No
|
No | No | No |
onstorage |
? | Yes | 45 | ? | ? | ? |
onunhandledrejection |
49 | Yes | No
|
No | No | No |
onunload |
Yes | Yes | Yes | Yes | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | ? | Yes | Yes | ? | ? |
onafterprint |
63 | 63 | Yes | ? | 50 | ? | ? |
onbeforeprint |
63 | 63 | Yes | ? | 50 | ? | ? |
onbeforeunload |
Yes | Yes | Yes | ? | Yes | No
|
? |
onhashchange |
Yes | Yes | Yes | 4 | 11 | 5 | ? |
onlanguagechange
|
37 | 37 | ? | 4 | 24 | ? | ? |
onmessage |
60 | 60 | ? | ? | 47 | ? | ? |
onmessageerror |
60 | 60 | ? | 57 | 47 | ? | ? |
onpopstate |
? | 18 | ? | 4 | 12 | 5.1 | ? |
onrejectionhandled |
No | No | ? | No
|
No | No | ? |
onstorage |
No | No | Yes | 45 | ? | ? | ? |
onunhandledrejection |
No | No | Yes | No
|
No | No | ? |
onunload |
Yes | Yes | Yes | Yes | Yes | Yes | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers