<body onUnload="">
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
- Attribute of
- HTML Body Tag: Master The Most Important HTML Element Now
- What does
<body onUnload="">
do? - Fires a script when the visitor leaves the page.
The onUnload
attribute is an event handler that instructs the browser to run a script when the visitor leaves the page.
Example usage
<body onUnload="script">
Points to be aware of
body
event handlers act on the browser window, so the onUnload
is commonly used to bring up JavaScript alert when the visitor exits a website. Some visitors may find this behavior unhelpful, so it’s best used sparingly.
Browser Support for onUnload
All | All | All | All | All | All |