JavaScript » eventhandler » onUnload

Syntax:
onUnload = myJavaScriptCode

Event handler for Window

The onUnload event handler is used to run a function or JavaScript code whenever the user exits a document. The onUnload event handler is used within either the <BODY> or the <FRAMESET> tag, and uses the following properties of the Event object:
 
type - indicates the type of event
target - indicates the target object to which the event was sent.
 
Compare to the onload event handler.

Examples

Code:
<BODY onUnload="finishOff()">
Explanation:

This example shows the onUnload event handler being used to execute the 'finishOff' function:

See Also: