onunload event
Example
Execute JavaScript code when the document is unloaded:
Try it »
Definition and Usage
The onunload event occurs when the user exits the page.
The onunload occurs when the user leaves the page (by clicking a link, submitting a form, closing the browser window, etc.).
Note: The onunload event also triggers the page load event (+ onload event).
Syntax
In HTML:
Event Object
Event Object