aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes 'Cancel' on alert doesn't stop the action Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark " Watch " New topic
Author

'Cancel' on alert doesn't stop the action

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
I want to give a warning to user when she tries to navigate away from the page. So I am using a 'Confirm' dialogue. Pressing cancel should stop her from leaving the page.

This is my function which is called from the onUnload of the body tag of the page.


When I click on 'Cancel' button (part of the form within the same page), then this code is called and if I press cancel in the dialogue, user stays on same page.
However, I press any outside link, which takes user to some other page, then pressing cancel in the dialogue doesn't stop user moving away from the page.

What can be wrong? Any ideas will help.

Thanks
Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Any one there ....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56153
    
  13

Please read this.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
It is impossible to keep the user on the page with onunload.

You can use onbeforeunload.

Eric
Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Terribly sorry for my impatience Bear!

Thanks for the reply Eric.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: 'Cancel' on alert doesn't stop the action
 
Similar Threads
back button,confirm dislog issue
Confirm message on submit
Check if updates were made before page unload
How to submit struts form based on user confirmation through javascript
Key Press problem on Link