{{ APIRef() }}
Summary
The unload
event is raised when the window is unloading its content and resources. The resources removal is processed after the unload
event occurs.
Syntax
window.onunload = funcRef;
funcRef
is a reference to a function.
Notes
Using this event handler in your page prevents Firefox 1.5 from caching the page in the in-memory bfcache. See Using Firefox 1.5 caching for details.
Browsers equipped with pop-up window blockers will ignore all window.open()
method calls in onunload
event handler functions.
You can and should handle this event through {{domxref("EventTarget.addEventListener","window.addEventListener()")}} and the {{event("unload")}} event. More documentation is available there.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}} | {{Spec2('HTML5.1')}} | |
{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}} | {{Spec2('HTML5 W3C')}} |
Browser compatibility
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} | {{CompatVersionUnknown()}} |