HTML onunload attribute
onunload
The purpose of the HTML onunload attribute is to execute a script when the associated elements unload.
Supported elements
HTML onunload attribute supports body and frameset elements.
Syntax
<ElementName onunload="value" >.....</ElementName>
Where ElementName is any supported element.
Type of value
Script.
Value
A script which is to be executed.
Default value
There is no default value of HTML onunload attribute.
Supported doctypes
When used with body element HTML 4.01 strict, HTML 4.01 transitional.
When used with frameset element HTML 4.01 frameset.
Example of HTML onunload attribute with body element
Result

View this example in a separate browser window
Example of HTML onunload attribute with body element
Example of HTML onunload attribute with frameset element
Result

View this example in a separate browser window
Example of HTML onunload attribute with frameset element
Previous: HTML onsubmit attribute
Next: HTML profile attribute
Test your Programming skills with w3resource's quiz.