A Thorough Examination of "Disabling the Back Button.", Part 2By Akhilesh Reddy
In Part 1 we examined a few potential ways to disable the back button, a commonly asked question on the ASPMessageboard. In this part we'll continue our examination of various techniques for preventing the user to return to the previous page!
My next area of research focused on the various rewiring the back button suggestions. An article by TJ Sylvester, Rewiring the Back Button, makes interesting reading but I noticed that when one clicks back it does not indeed take you to the page you entered the data but if I clicked back twice it does and we would not want that too. Basically a determined user could always figure out a way to circumvent the preventative measures.
Again this is workable but it is far from the best way.
I was then given the suggestion to use
location.replace to navigate form one page to another.
What this does is it replaces the current history entry with the new page so only one page will be maintained
in the history and the back button will never get enabled. This is, I guess, what a lot of people are looking
for, but again this would not be the best answer in all cases.
For one thing you will have to use client side script for this. For an anchor tag this will be easy by just using:
The above technique has its disadvantages: simply using
Response.Redirect will not work, since,
each time a user jumps from one page to another, you need to clear out the
through client-side code. Also, keep in mind that this will just remove the last history entry, not all
of them. Go ahead and click the above hyperlink, you will be taken to a simple HTML page. Try clicking the back button
and you will notice you will be taken to the page you were visiting before you came to this page! (Assuming,
After my exhaustive search I found that there is still no way of truly disabling the back button for all cases. All the methods I discussed in this article will, with varying degrees of success, prevent the user from viewing the previous page, but they, of course, all have their limitations. The best solution involves a mixture of both client-side and server-side script; regardless, there is no way to completely disable the back button... sorry!