Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Use of the Back Button (in IE)

So the SMEs at my current place of employment want to try and disable the back button for certain pages. We have a page where the user makes some selections and submits them to be processed. In some instances they have to enter a comment on another page.

What the users have figured out is that they don't have to enter a comment if they submit the information and go to the page with the comment and then hit the back button to return to the previous page.

I know there are several different solutions to this (and many of them are far more elegant then disabling the back button), but this is what I'm left with. Is it possible to prevent someone from going back to the previous page through altering the behavior of the back button. (like a submit -> return false sorta thing).

Due to double posting information I can't have it return to the previous page and then move to the current one. I can only have it not direct away from the current page. I Googled it, but I only saw posts saying that it will always return to the previous page. I was hoping that someone has some mad kung foo js skills that can make this possible.

I understand that everyone says this is a bad idea, and I agree, but sometimes you just have to do what you're told.

like image 746
kemiller2002 Avatar asked Sep 10 '08 16:09

kemiller2002


1 Answers

Don't do this, just don't. It's bad interface design and forces the user's browser to behave in a way that they don't expect.

I would regard any script that successfully stopped my back button from working to be a hack, and I would expect the IE team to release a security-fix for it.

The back button is part of their program interface, not your website.

In your specific case I think the best bet is to add an unload event to the page that warns the user if they haven't completed the form. The back button would be unaffected and the user would be warned of their action.

like image 53
Keith Avatar answered Sep 29 '22 11:09

Keith