aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Disabling 'Back' button of the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disabling Watch "Disabling New topic
Author

Disabling 'Back' button of the browser

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Friends
I have a situation in which I do not want user to use
back button of browser.
how it is possible?
Please help.
Jaisinh
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
You can open up a popup window that doesn't have the toolbar. They can still use the right click, but if you opened a new window, then they don't have anything in thier history so back wouldn't do anything anyways.
Bill
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks Bill,
This is ok when there is just a sing screen.
My application is moving through pages and collecting information from user on different questions.
In this situation how we can disable Back button.
Jaisinh
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
If that is the case, I don't think you can. Back button has to do with the users history, so you may be able to play with thier history, but I don't think you can disable it. You can hide it as I said with a pop-up, and then capture the persons right click so they can't right-click and go back, but if they have javascript turned off you are out of luck. And whenever I go to a site and they disable my right click, I always turn off my javascript to find out why.
Bill
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Maybe you could do this with an applet? You could embed a JEditorPane in a JApplet and use it to display your HTML pages. Then you could control what is being displayed using Java. Since all of this would be in a single HTML doc with the Applet embedded in it, the back button would not be relevant?
What are your thoughts on this, Bill?
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Good idea Bodie, development time would increase, but you are right the back button would only take you to the page right before the form, so that would work. Not sure if it would be worth it considering the extra time to develop, but doable.
Bill
Danny Mui
Ranch Hand

Joined: Dec 14, 2000
Posts: 42
If you're using a server page/servlet technology, you can stuff a token in the session to validate with a page (i.e. page 1 expects token 234223 and gets assigned a diff one after page 2 is loaded...).
ali farid
Ranch Hand

Joined: Aug 26, 2000
Posts: 60

Maybe this link will help
http://www.webreference.com/js/tips/990923.html
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Very slick!
milan doshi
Ranch Hand

Joined: Nov 03, 2000
Posts: 43
If we are using Servlets , we can do it using the headers !
The whole idea is that when a page is downloaded it is stored in the cache. hence if we give a command while sending a page that it should not be stored in the cache that WILL WORK. That means when the Browsers back button is clicked it will not get anything for the simple reason that the page is not stored in the temporary memory.
Hence HttpResponse Header is to be used .
Regards,
Milan Doshi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disabling 'Back' button of the browser