Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

onunload event

onunload event

Event Object Reference Event Object

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