window.onUnLoad

Nav2+, IE3+, Opera3+ Syntax

onUnLoad="command"

Description

The onUnLoad event handler of a property of a Window object is fired when the page is unloaded in that particular window instance. This occurs when the user leaves the page for another page.

Note

The onUnLoad event handler in the <body> of a document that is loaded in a frame will fire before an event handler loaded in the <frameset> tag that loaded the document.

Example

Listing 7.562 pops up an alert box when the user leaves the page.

Listing 7.562 Example of Using the onUnLoad Event
<body onUnLoad='alert("Please do not leave!")'>
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.