Jump to content
Ezio

Why onunload() does not work ..?

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. :-(

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I use unload handlers to run functions on the parent window when a child window is closed.

 

Oh, there's an idea I hadn't thought of.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...