trigger an onunload event

Hi!
How to trigger a event when closing or refreshing a browser?
Thanks.

Re: trigger an onunload event

Hello,
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.