Page 1 of 1

Is it possible to stop a page from loading with onUnload?

Posted: Fri Oct 28, 2005 1:17 pm
by myleow
Hi guys,

I am messing around with onUnload and would like to know if there is a way to stop users from going to other pages if there were changes in the current page.

Like i change some field values and then click on something else (another page link) besides the Update Cart button, i would like to make it so that they get an Alert saying You made changes please click on Update Cart first and stop the redirection.

You can check it out at http://www.impressiondesign.com/deanes/ add something to the cart and then go to view cart, if you change something on the cart (quantity) and click on Products or any other links besides Update Cart button or Checkout button. I want it to stop the loading of the page and stay in that page.

Thank you for your help in advance.

Regards
Mian

Posted: Fri Oct 28, 2005 1:33 pm
by Burrito
onUnload is all but phased out... you should just check on the server side then send them back if the stuff is not the way you want it.

Posted: Mon Oct 31, 2005 1:55 pm
by myleow
Yeah i ended up giving up on the idea of using it. Thanks for the information.

Posted: Mon Oct 31, 2005 2:42 pm
by foobar
Burrito wrote:onUnload is all but phased out...
Uh, no. MSN WebMessenger uses it, my router's html interface uses it, and most other web chat applications that log the user off once they've quit the page (including one I wrote).

Posted: Mon Oct 31, 2005 2:49 pm
by Burrito
in what capacity do they use it? In other words, how is it used effectively? Does it pop-up a new window?

Posted: Mon Oct 31, 2005 2:52 pm
by Chris Corbyn
Burrito wrote:in what capacity do they use it? In other words, how is it used effectively? Does it pop-up a new window?
Popup blockers will stop that. You may still be able to throw an alert box but I guess that *might* be blocked too.

The only things I can think of onunload working for are data transmissions using ajax or such, back to the server.

Posted: Mon Oct 31, 2005 2:54 pm
by Burrito
d11wtq wrote: Popup blockers will stop that. You may still be able to throw an alert box but I guess that *might* be blocked too.
precisely my point....

Posted: Mon Oct 31, 2005 3:49 pm
by foobar
Burrito wrote:in what capacity do they use it? In other words, how is it used effectively? Does it pop-up a new window?
Forget it, I was thinking of onBeforeUnload. Stupid me. :oops: