onunload Event

DHTML, HTML, & CSS

 
Click to return to the DHTML, HTML & CSS home page    
onsubmit Event     DHTML Events    

onunload Event


Fires immediately before the object is unloaded.

Syntax

Inline HTML <ELEMENT onunload = "handler" ... > All platforms
Event property object.onunload = handlerJScript (compatible with ECMA 262 language specification) only
Named script <SCRIPT FOR = object EVENT = onunload> Internet Explorer only

Remarks

BubblesNo
CancelsNo
To invoke
  • Close the current browser window.
  • Navigate to another location by entering a new address or selecting a Favorite.
  • Click the Back, Forward, Refresh, or Home button.
  • Click on an anchor that refers the browser to another Web page.
  • Invoke the anchor click method.
  • Invoke the document write method.
  • Invoke the document open method.
  • Invoke the document close method.
  • Invoke the window close method.
  • Invoke the window open method, providing the possible value _self for the window name.
  • Invoke the window navigate or NavigateAndFind method.
  • Invoke the location replace method.
  • Invoke the location reload method.
  • Specify a new value for the location href property.
  • Submit a FORM to the address specified in the ACTION attribute via the INPUT_submit control, or invoke the form submit method.
Default action Removes the object or document from the browser window.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, the handler can query the event object for data.

Event Object Properties

typeRetrieves the event name from the event object.

Example

This example shows how to use the onunload event to run script when the window object has been unloaded.

<HEAD>
<SCRIPT FOR=window EVENT=onunload>
    alert("The onunload event fired for the window object.");
</SCRIPT>

<SCRIPT>
    function fnRelocate()
    {
    location.href="/workshop/samples/author/dhtml/refs/onunloadEX_target.htm";
    }
</SCRIPT>
</HEAD>
<BODY>
  <INPUT TYPE=button VALUE="Go To Page 2" onclick="fnRelocate()">
  <IMG ID=imgTest SRC="/workshop/graphics/prop_rw.gif">
</BODY>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
FRAMESET, window

See Also

onload


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.