Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
08-14-2005, 12:44 AM #1
- Join Date
- Aug 2002
- Oregon, United States of America
- Thanked 9 Times in 9 Posts
prompt before allowing back button
I need to find a way, so that if the user clicks the back button on the browser, i can prompt them, and potentialy disallow the use of the back button.
*Click back button*
Are you sure you want to go back? Data will be lost!
The page dosnt change.
If anyone knows how i can do this, plz inform.If I'm postin here, I NEED YOUR HELP!!
08-15-2005, 04:04 PM #2
- Join Date
- Jun 2005
- Near Chicago, IL, USA
- Thanked 32 Times in 31 Posts
Cannot be done reliably.
You can put code in the onunload of the page to TRY, but it doesn't always fire.
You can try to remove the back button, but I have keyboard shortcuts to go back and my right-click menu.
You can try to take that away, but I have a quick bookmarklet to get it back b/c it really irritates me when people do that.
So, you can try to save the user from himself/herself, but your best bet is to inform them in plain text at the top of the page...
IF YOU LEAVE THIS PAGE WITHOUT SAVING (INCLUDING HITTING BACK BUTTON) YOUR DATA WILL BE LOST.
If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/