aspose file tools*
The moose likes JSP and the fly likes onUnload() -- Very URGENT !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "onUnload() -- Very URGENT !!!" Watch "onUnload() -- Very URGENT !!!" New topic
Author

onUnload() -- Very URGENT !!!

Tejas Tambe
Ranch Hand

Joined: Oct 08, 2001
Posts: 47
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

Joined: Mar 09, 2000
Posts: 34
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

Joined: Oct 08, 2001
Posts: 47
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

Joined: Dec 19, 2002
Posts: 374
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.


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
Here's an even better article...
http://www.webreference.com/dhtml/diner/beforeunload/
 
Consider Paul's rocket mass heater.
 
subject: onUnload() -- Very URGENT !!!