Execute a JavaScript when a user unloads the document:
The onunload event attribute is supported in all major browsers.
The onunload attribute fires once a page has unloaded (or the browser window has been closed).
onunload occurs when the user navigates away from the page (by clicking on a link, submitting a form, closing the browser window, etc.)
Note: If you reload a page, you will also trigger the unload event (and the onload event).
None.
| Value | Description |
|---|---|
| script | The script to be run on onunload |
HTML Event Attributes
Your message has been sent to W3Schools.