onUnload (Event handler)

Triggered when the document is unloaded.


JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera browser - 3.0
Property/method value type:Boolean primitive
JavaScript syntax:-myObject.onunload = aHandler
HTML syntax:<BODY onUnload="aHandler"> <FRAMESET onUnload="aHandler"> <HTMLTag onUnload="aHandler">
Argument list:aHandlerA reference to a function object to handle the event

The onUnload event is triggered for a <BODY> or <FRAMESET> tag when the page is about to disappear and be replaced with another. You should avoid doing anything lengthy or complex here - it should just be used to do some cleaning up.

It is considered bad technique to place an alert or any other dialog in the onUnload handler. It is also bad manners to tie the processing up in a lengthy piece of script execution at this stage.

You might use the unLoad handler to remove any values you put into the window status bar.

Although this is a tag attribute that is applied to the <BODY> tag, it is really associated with the Window object in which the document body is loaded.


See also:Event, Event handler, Event model, Event names, Event object, Event.returnValue, Handler, JellyScript, onBeforeUnload, onLoad, Semantic event, Window events, Window.onunload

Supported by objects: