Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Client Scripting
Expertise: Beginner
Jun 3, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Disabling the Browser Back Button

Is there a method that will prevent a user from going back to the previous page without modifying the browser code? (Does it matter if it is a CGI generated page?). Of course it would nice if this worked on both IE 4.x and Netscape 4.x.

Unfortunately you can't prevent users from using their "Back" buttons. Similarly, you can't prevent them from bookmarking a previous page and then jumping to it directly. If you have a multi-step process and you don't want people to go back to a previous step once they've completed it then a cookie-based solution may do the trick. When they start the process set a cookie on the user's browser (using document.cookie) to a value of 1. Each time they advance a step in the process set this cookie-based counter to the step number they're on. At the beginning of every page in the process check the value of the counter to make sure that it isn't higher than the number of the step associated with that page. If it is higher redirect them to the step they should be on. If the cookie is missing, redirect the user to the start of the process.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date