tags:

views:

46

answers:

2

How can i disable browser from going back to a particular page? My scenario is Login page -> change password page ->user returns to login page again-> (on browser back should not go back to change password page) but currently it goes to the change password page. I am currently working on a grails application. How can i solve this issue?

A: 

Use javascript's location.replace() function:

http://www.roseindia.net/javascript/javascript-location-replace.shtml

Palantir
+1  A: 

You can't stop users from going back if they want to, because a browser can do whatever it feels like.

But if you only want to prevent users from going back accidentally, then just make the "change password" page only appear in response to an HTTP POST (not just a URL link, which is an HTTP GET request). Most browsers will give a warning about re-submitting the form if the previous page was the result of a POST request.

Daniel Pryden
While valid, this advice ends up "breaking the back button".
Shaggy Frog
@Shaggy: Yes. Isn't that exactly what the OP was asking for?
Daniel Pryden