---
title: WindowEventHandlers
slug: Web/API/WindowEventHandlers
tags:
- API
- HTML-DOM
- Interface
- NeedsTranslation
- Reference
- TopicStub
translation_of: Web/API/WindowEventHandlers
---
{{APIRef("HTML DOM")}}
WindowEventHandlers
mixin 描述了事件处理程序常见的一些公共接口 ,例如{{domxref("Window")}}和 {{domxref("HTMLBodyElement")}} 和 {{domxref("HTMLFrameSetElement")}}等这些接口都实现了下列特定的事件处理程序。
WindowEventHandlers不是一个接口,没有这种类型的对象可以创建。
Properties
The events properties, of the form onXYZ
, are defined on the {{domxref("WindowEventHandlers")}}, and implemented by {{domxref("Window")}}, and {{domxref("WorkerGlobalScope")}} for Web Workers.
- {{domxref("WindowEventHandlers.onafterprint")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("afterprint")}} event is raised.
- {{domxref("WindowEventHandlers.onbeforeprint")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("beforeprint")}} event is raised.
- {{domxref("WindowEventHandlers.onbeforeunload")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("beforeunload")}} event is raised.
- {{domxref("WindowEventHandlers.onhashchange")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("hashchange")}} event is raised.
- {{domxref("WindowEventHandlers.onlanguagechange")}} {{experimental_inline}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("languagechange")}} event is raised.
- {{domxref("WindowEventHandlers.onmessage")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("message")}} event is raised.
- {{domxref("WindowEventHandlers.onoffline")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("offline")}} event is raised.
- {{domxref("WindowEventHandlers.ononline")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("online")}} event is raised.
- {{domxref("WindowEventHandlers.onpagehide")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("pagehide")}} event is raised.
- {{domxref("WindowEventHandlers.onpageshow")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("pageshow")}} event is raised.
- {{domxref("WindowEventHandlers.onpopstate")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("popstate")}} event is raised.
- {{domxref("WindowEventHandlers.onstorage")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("storage")}} event is raised.
- {{domxref("WindowEventHandlers.onunhandledrejection")}} {{experimental_inline}}
- An event handler for unhandled {{jsxref("Promise")}} rejection events.
- {{domxref("WindowEventHandlers.onunload")}}
- Is an {{event("Event_handlers", "event handler")}} representing the code to be called when the {{event("unload")}} event is raised.
Methods
This interface defines no method.
Specifications
Specification |
Status |
Comment |
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}} |
{{Spec2('HTML WHATWG')}} |
No change since the latest snapshot, {{SpecName("HTML5.1")}}. |
{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}} |
{{Spec2('HTML5.1')}} |
Snapshot of {{SpecName("HTML WHATWG")}}. Added onlanguage since the {{SpecName("HTML5 W3C")}} snapshot. |
{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}} |
{{Spec2('HTML5 W3C')}} |
Snapshot of {{SpecName("HTML WHATWG")}}. Creation of WindowEventHandlers (properties where on the target before it). |
Browser compatibility
{{CompatibilityTable}}
Feature |
Firefox (Gecko) |
Chrome |
Internet Explorer |
Opera |
Safari |
Basic support |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
onhashchange |
{{CompatGeckoDesktop(1.9.2)}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
onlanguage {{experimental_inline}} |
{{CompatGeckoDesktop(32)}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
onstorage |
{{CompatGeckoDesktop(45)}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
Feature |
Firefox Mobile (Gecko) |
Android |
IE Mobile |
Opera Mobile |
Safari Mobile |
Basic support |
{{CompatVersionUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
onhashchange |
{{CompatGeckoMobile(1.9.2)}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
onlanguage {{experimental_inline}} |
{{CompatGeckoMobile(32)}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
onstorage |
{{CompatGeckoDesktop(45)}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
See also
- {{domxref("Window")}} and {{domxref("WorkerGlobalScope")}}