Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stopping page by onUnload handler

 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a question whe a user tries to go to a different page I am checking for some condition and if condition is true I am allowing him to move to next page otherwise same page will be displayed.
This i m doing in onUnload handler, but if condition is false i want to stop unloading of current page .
How do do this?? i tried window.stop();
and document.execCommand('stop'); but it did't worked.
thanks for ur time.
Anurag
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to try
document.location.href="theUrl"
I do no think it will work
 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,
Its not what i m looking I just want a way to stop loading a page one i call onunload eventhandler.
If you get time pls reply.
thanks
Anurag
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it on IE only using onbeforeunload handler.
There is no way to do it using onunload. Best you can do, is to call alert, so the page will stay until user hits "OK".
 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yuri,
thanks a lot for your reply but onbeforeunload displays its own message I know we can customize this message but we cannot customize it
totally as if we use this we need to display Microsoft's messages also.
pls put your comments.
thanks
anurag
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are stuck with what you got,
I would use a different approach where you send the links to a function and check it that way. If it is true then let them advance by changing the link

This wil not stop yping into the Addy bar or closing the browser or the forward buttons
Eric
 
Jeramie Maratas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
I want to do the same thing: invoke the stop method of the web browser. If you were able to solve your problem, can you give me an idea on how to go about it? Thanks and more power.

Best Regards,
Jen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic