• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

onUnload() -- Very URGENT !!!

 
Tejas Tambe
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I want to display a confirm message 'Are you sure u want to quit ?', when user presses the [X] button. But, the onUnload() closes the window first and then displays the message.
Is there any way to display the message first and close the window ???
 
Veena Rani
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use onbeforeunload event in place of onUnload this will display the message before closing the window. But i dont think you can prevent the closing of window according to user respose to message displayed.
Veena
 
Tejas Tambe
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Veena,
I tried the onbeforeunload event, and it works.
I have found a solution on which I can stop the unload event, by returning false to onbeforeunload.

But the problem here is that, IE itselfs prompts a message saying,
Are you sure you want to navigate from the current page.

Is there any way to disable this message from IE ?
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that's interesting. I did a google search on onbeforeunload and came up with some MickeySquish docs on the subject:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onbeforeunload.asp
Apparently you cannot remove or alter this message--see the remarks section.
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an even better article...
http://www.webreference.com/dhtml/diner/beforeunload/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic