Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'Cancel' on alert doesn't stop the action

 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any one there ....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is impossible to keep the user on the page with onunload.

You can use onbeforeunload.

Eric
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Terribly sorry for my impatience Bear!

Thanks for the reply Eric.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic