Advertisement
Home Open Editor ❯

HTML onunload Attribute

Example

<body onunload="myFunction()">

Try this code ❯

Meaning

The onunload attribute specifies that the browser is leaving the current document and unloading it from the window or frame.

There may be another possible use for this event when elements bind to remote data sources and unload.


Standard Syntax

<element onunload="script">


Applies to:

The onunload attribute can be used on the following element:

Element Attribute
<body> onunload

Advertisement

Attribute Values

Value Description
script Specifies the script to be run on onunload.
Home Open Editor ❯
Advertisement