Hi, How can I disable the back button of the browser? I want to stay on the same page when the user clicks the back button without doing any action. Any help would be appreciated.
Mani Ram
Ranch Hand
Joined: Mar 11, 2002
Posts: 1140
posted
0
HTML/Javascript is more apt for this thread, I guess.
Simple answer: You can't.
There are ways to disable the back button (by removing the tool bar etc), but there are lot of other ways using which the user can navigate to the previous page (using Backspace button, right click and click 'Back' etc)
The proper way to solve the problem is to design your system in a way to manage such behaviours (back, forward, refresh etc).
Mani
Quaerendo Invenietis
Vishnu Prakash
Ranch Hand
Joined: Nov 15, 2004
Posts: 1026
posted
0
How can I disable the back button of the browser?
You cannot disable back browser button from server side code
Originally posted by Ajith George: You can disable back button of your browser by including the following javascript on that page.
I tried this in IE and it causes the page to automatically send you back one page, which is close to the opposite of "disabling the back button"! Are you sure this is what you meant?
There is no emoticon for what I am feeling!
Ajith George
Ranch Hand
Joined: Dec 22, 2005
Posts: 109
posted
0
Sorry there was a mistake. The correct way of doing is
Try this !
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Originally posted by Ajith George: Sorry there was a mistake. The correct way of doing is
That doesn't seem to work either. Try it:
Are you sure that you know how to do this?
Ajith George
Ranch Hand
Joined: Dec 22, 2005
Posts: 109
posted
0
It's working for me. This is code for test2.jsp And this is code for test3.jsp
Both jsp's have almost same code and both have links between them. When i reached test3.jsp from test2.jsp, ican't return back using my back button. Vice versa too it's working. Try this !
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Thanks! I understand now Here's a simpler example, because your example with links going between two pages hides the hack:
When you visit page 1 the back key is functional (this is why I thought history.forward isn't working). Then you follow the link to page two, and the back button is still *enabled* but when you click on it *that's* when the forward method successfully fires and sends you back to page 2. Maybe I'm hoping for too much, but is there a solution that truly *disables* the back button? [ March 29, 2006: Message edited by: Jeff Albertson ]
No doubt there is a simple hack. But there is not a solution to the problem that "disabling the back button" is supposed to solve.
Let's suppose you manage to disable the back button on my browser. When I find you have done that I mutter something about your mother. Then I right-click on the link, and open the new page in a separate tab. Then when I want to go back to the page I just came from, it's right there in the first tab. Not only is your problem not solved but you provided me with an annoying interface as well.
At this point the true fanatic will try to prevent me from right-clicking on links. And to prevent me from using that drop-down thing next to the back button which lets me go back to any of the last few pages I viewed. And to prevent me from using the "Back" option on my browser's menu. The professional will get a life and write their server to work properly when these browser features are used.