Jump to content

Why onunload() does not work ..?


Ezio

Recommended Posts

Hey guys,

I have a small problem here the onunload event does not work on my firefox...don't know why.

this was the example i tried to run on my browser it's from w3schools

 

<!DOCTYPE html><html><head><script>function goodbye(){alert("Thank you for visiting W3Schools!");}</script></head><body onunload="goodbye()"><h1>Welcome to my Home Page</h1><p>Close this window or press F5 to reload the page.</p></body></html>

 

but it won't work. :-(

Link to comment
Share on other sites

Have you checked the browser support?

http://www.w3schools.com/jsref/event_onunload.asp

The onunload event is supported in IE, Firefox, and Safari, but not supported properly in Chrome or Opera.

Also remember ActiveX Script have to be allowed to this happen (atleast on IE)

Edited by Mudsaf
Link to comment
Share on other sites

maybe they were working on a form that required you to store information in a cookie. you could use unload to wipe the cookies to make sure none of the data persists.

 

http://api.jquery.com/unload/

 

This event is available so that scripts can perform cleanup when the user leaves the page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...