onunload Event
Complete Event Object Reference
Definition and Usage
The onunload event occurs when a user exits a page.
Syntax
onunload="SomeJavaScriptCode"
|
Parameter |
Description |
SomeJavaScriptCode |
Required. Specifies a JavaScript to be executed when the
event occurs. |
Supported by the following HTML tags:
Supported by the following JavaScript objects:
Example
In this example an alert box will be displayed when the page is closed:
<body onunload="alert('The onunload event was triggered')">
</body>
|
Try-It-Yourself Demos
onunload
How to use onunload.
Complete Event Object Reference
…
|