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.onafterprintIs an event handler representing the code to be called when the afterprint event is raised.
WindowEventHandlers.onbeforeprintIs an event handler representing the code to be called when the beforeprint event is raised.
WindowEventHandlers.onbeforeunloadIs an event handler representing the code to be called when the beforeunload event is raised.
WindowEventHandlers.onhashchangeIs an event handler representing the code to be called when the hashchange event is raised.
WindowEventHandlers.onlanguagechange
Is an event handler representing the code to be called when the languagechange event is raised.
WindowEventHandlers.onmessageIs an event handler representing the code to be called when the message event is raised.
WindowEventHandlers.onmessageerrorIs an event handler representing the code to be called when the MessageError event is raised.
WindowEventHandlers.onofflineIs an event handler representing the code to be called when the offline event is raised.
WindowEventHandlers.ononlineIs an event handler representing the code to be called when the online event is raised.
WindowEventHandlers.onpagehideIs an event handler representing the code to be called when the pagehide event is raised.
WindowEventHandlers.onpageshowIs an event handler representing the code to be called when the pageshow event is raised.
WindowEventHandlers.onpopstateIs an event handler representing the code to be called when the popstate event is raised.
WindowEventHandlers.onrejectionhandledIs an event handler 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.onstorageIs an event handler representing the code to be called when the storage event is raised.
WindowEventHandlers.onunhandledrejectionIs an event handler 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.onunloadIs an event handler representing the code to be called when the unload event is raised.
This interface defines no method.
| Specification |
|---|
| HTML Standard (HTML) # windoweventhandlers |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
WindowEventHandlers |
1 |
12 |
1 |
4 |
≤12.1 |
1 |
1 |
18 |
4 |
≤12.1 |
1 |
1.0 |
onafterprint |
63 |
12 |
6 |
≤6 |
50 |
13 |
63 |
63 |
? |
46 |
13 |
8.0 |
onbeforeprint |
63 |
12 |
6 |
≤6 |
50 |
13 |
63 |
63 |
? |
46 |
13 |
8.0 |
onbeforeunload |
1 |
12 |
1 |
4 |
12 |
3 |
1 |
18 |
4 |
12 |
1 |
1.0 |
onhashchange |
5 |
12 |
3.6 |
8 |
10 |
5 |
≤37 |
18 |
4 |
10.1 |
5 |
1.0 |
onlanguagechange |
37 |
79 |
32 |
No |
24 |
10.1 |
37 |
37 |
4 |
24 |
10.3 |
4.0 |
onmessage |
60 |
12 |
9 |
8 |
47 |
4 |
60 |
60 |
9 |
44 |
4 |
8.0 |
onmessageerror |
60 |
18 |
57 |
No |
47 |
No
See bug 171216.
|
60 |
60 |
57 |
44 |
No
See bug 171216.
|
8.0 |
onoffline |
3 |
12 |
9 |
9 |
15 |
4 |
≤37 |
18 |
9 |
14 |
3 |
1.0 |
ononline |
3 |
12 |
9 |
9 |
15 |
4 |
≤37 |
18 |
9 |
14 |
3 |
1.0 |
onpopstate |
5 |
12 |
4 |
10 |
11.5 |
5 |
37 |
18 |
4 |
11.5 |
4.2 |
1.0 |
onrejectionhandled |
49 |
79 |
69
68
55
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.
|
No |
36 |
11 |
49 |
49 |
68
55
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.
|
No |
11.3 |
5.0 |
onstorage |
1 |
15 |
45 |
9 |
15 |
4 |
≤37 |
18 |
45 |
14 |
4 |
1.0 |
onunhandledrejection |
49 |
79 |
69
68
55
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.
|
No |
36 |
11 |
49 |
49 |
68
55
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.
|
No |
11.3 |
5.0 |
onunload |
1 |
12 |
9 |
≤6 |
≤12.1 |
1 |
≤37 |
18 |
9 |
≤12.1 |
1 |
1.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers