Helping ordinary people create extraordinary websites!
   

How to use JavaScript unload event?

Tuesday, 12th January 2010
by Bonded

How does the JavaScript unload event work and what are some ways in which it can be used. Any examples would be appreciated.





Vader
The JavaScript onUnload event handler is useful to provide users with messages or options when they are leaving your page. For example you may want to display a message to your users informing them about a promotion or something else when they are leaving your page.

The code to achieve this can be accomplished using the following code:

<body onUnload="alert('Message you want to show user goes here.')">

Vader.
Thursday, 14th January 2010
Votes:
14
12

More JavaScript Help:
» Write a javascript code that verifies all textboxes has been filled.
» Could anyone provide a javascript to send an email
» JavaScript random number?
» How to submit a form to open in a popup window?
» How to limit in real-time the number of characters in textarea with JavaScript?
» How to create an online voting or survey system using JavaScript?
» How to download free scripts?
» JavaScript URLEncode?