HTML onunload Attribute

❮ HTML Attributes

Example

<body onunload="myFunction()">

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">



Browser Support




Status




Applies to:

The onunload attribute can be used on the following element:

Element Attribute
<body> onunload






Attribute Values

Value Description
script Specifies the script to be run on onunload.
❮ HTML Attributes