HTML onunload event Attribute

❮ HTML Event Attributes


<body onunload="myFunction()">


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


Attribute Values

Value Description
script Specifies the script to be run on onunload.

Technical Details

Supported HTML elements:

❮ HTML Event Attributes