Unfortunately, this handler is not guarantee that you can execute any code in that handler. For example, you're able to execute a alert(''); but you won't be able to send HTTPRequest. It happens because the browser will terminate all client threads before the code will be executed.
Re: trigger an onunload event
1 April, 2008 - 09:15 — RusHello,
You can catch this event in inline event handler "onunload" that you could add on the "body" tag. This code will show you how to do that:
<body onunload="alert('I\'am unloaded!');">
...
</body>
...
Unfortunately, this handler is not guarantee that you can execute any code in that handler. For example, you're able to execute a
alert('');but you won't be able to send HTTPRequest. It happens because the browser will terminate all client threads before the code will be executed.