Our volunteers haven't translated this article into עברית yet. Join us and help get the job done!
You can also read the article in English (US).

The onunload property of the WindowEventHandlers mixin is the EventHandler for processing unload events. These events fire when the window is unloading its content and resources. The resource removal is processed after the unload event occurs.

Note: Browsers equipped with pop-up blockers will ignore all Window.open() method calls in onunload event handler functions.


window.addEventListener("unload", function(event) { ... });
window.onunload = function(event) { ... };

Typically, it is better to use window.addEventListener() and the unload event, instead of onunload.


Specification Status Comment
HTML Living Standard
The definition of 'onunload' in that specification.
Living Standard  
HTML 5.1
The definition of 'GlobalEventHandlers' in that specification.
The definition of 'GlobalEventHandlers' in that specification.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onunloadChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?


Full support  
Full support
Compatibility unknown  
Compatibility unknown

In Firefox 1.5, using this event handler in your page prevents the browser from caching the page in the in-memory bfcache. See Using Firefox 1.5 caching for details.