Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | onunload Event Attribute

  • Last Updated : 03 Aug, 2021

The onunload event attribute works when the document is being unloaded i.e. it occurs when the browser has been closed. It is mostly used when the user open link and submit the form and close the browser window. 
Supported Tags: 

  • <body>


<element onunload = "script">

Attribute Value: This attribute contains single value script which works when onunload event triggered.


<!DOCTYPE html>
            HTML onunload Event Attribute
            function Geeks() {
                alert("onunload event attribute called");
    <body onunload = "Geeks()">
        <h2>onunload Event Attribute</h2>


Note: This event may not work always as expected.
Supported Browsers: The browser supported by onunload event attribute are listed below: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!