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 event handler representing the code to be called when the
afterprintevent is raised. WindowEventHandlers.onbeforeprint-
Is an event handler representing the code to be called when the
beforeprintevent is raised. WindowEventHandlers.onbeforeunload-
Is an event handler representing the code to be called when the
beforeunloadevent is raised. WindowEventHandlers.onhashchange-
Is an event handler representing the code to be called when the
hashchangeevent is raised. -
WindowEventHandlers.onlanguagechange -
Is an event handler representing the code to be called when the
languagechangeevent is raised. WindowEventHandlers.onmessage-
Is an event handler representing the code to be called when the
messageevent is raised. WindowEventHandlers.onmessageerror-
Is an event handler representing the code to be called when the
MessageErrorevent is raised. WindowEventHandlers.onoffline-
Is an event handler representing the code to be called when the
offlineevent is raised. WindowEventHandlers.ononline-
Is an event handler representing the code to be called when the
onlineevent is raised. WindowEventHandlers.onpagehide-
Is an event handler representing the code to be called when the
pagehideevent is raised. WindowEventHandlers.onpageshow-
Is an event handler representing the code to be called when the
pageshowevent is raised. WindowEventHandlers.onpopstate-
Is an event handler representing the code to be called when the
popstateevent is raised. WindowEventHandlers.onrejectionhandled-
Is an event handler representing the code to be called when the
rejectionhandledevent is raised, indicating that aPromisewas rejected and the rejection has been handled. WindowEventHandlers.onstorage-
Is an event handler representing the code to be called when the
storageevent is raised. WindowEventHandlers.onunhandledrejection-
Is an event handler representing the code to be called when the
unhandledrejectionevent is raised, indicating that aPromisewas rejected but the rejection was not handled. WindowEventHandlers.onunload-
Is an event handler representing the code to be called when the
unloadevent is raised.
Methods
This interface defines no method.
Specifications
| Specification |
|---|
| HTML Standard (HTML) # windoweventhandlers |
Browser compatibility
| 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 |
3 |
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 |
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 |
≤4 |
≤37 |
18 |
9 |
≤12.1 |
≤3 |
1.0 |
See also
© 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