Latest

recent

JavaScript onunload Event

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:

<body>, <frameset>

Supported by the following JavaScript objects:

window


Example

In this example an alert box will be displayed when the page is closed:

<body onunload="alert('The onunload event was triggered')">
</body>
JavaScript onunload Event Reviewed by 1000sourcecodes on 03:56 Rating: 5
Powered by Blogger.