Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

window.onunload

Test Summary

The unload event is raised when the document is unloaded.

Syntax

window.onunload = funcRef;
  • funcRef is a reference to a function.

Example

<html>
<head>

<title>onunload test</title>

<script type="text/javascript">

window.onunload = unloadPage;

function unloadPage()
{
 alert("unload event detected!");
}
</script>
</head>

<body>
<p>Reload a new page into the browser<br />
 to fire the unload event for this page.</p>
<p>You can also use the back or forward buttons<br />
 to load a new page and fire this event.</p>
</body>
</html>

Notes

Note that 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.

Specification

DOM Nivel 0. No es parte de ninguna norma.

Etiquetas y colaboradores del documento

 Colaboradores en esta página: fscholz, khalid32, Sheppy
 Última actualización por: khalid32,