Remove BODY onunload Event After Page Has Loaded
The onunload can be used to perform an action or to call a function when the user leaves a webpage.
There are scenarios however when you might want to remove this action after the page has loaded. Take a look at the simple example below where I present a very basic HTML page containing an onunload attribute on the <body> tag, then also a link that, when clicked, removes this onunload event:
<html> <body onunload="alert('Unloading Body');"> <a href="#" onclick="document.body.onunload = null;">Click me to remove body onunload</a> </body> </html>