File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Browser Back Button 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 "Browser Back Button " Watch "Browser Back Button " New topic

Browser Back Button


Joined: Nov 12, 2001
Posts: 18
Can i disable the back button of browser through javascript
James Hobson
Ranch Hand

Joined: Aug 28, 2001
Posts: 140
You can try -- but it is never going to be reliable -- different implementations of javascript, people disable javascript etc.
The best thing to do, is assign a transaction number to each page view (eith stick it onto the URL with ?transID=xxx or put it in a hidden field (just like you do with re-written URLs -- then let the server ignor requests that do not come from the correct page.
That way people can go back, but at least the server will know.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Like James said, there isn't really any complete and safe way to implement it, but I've seen it it done with moderate success using JSPs and Servlets, implementing a Model-View-Controller (MVC) pattern with a global controller and allowing the controller to dictate the page displayed. (with the additional functionality to prevent the client from caching pages)
If you can find a solution that doesn't require disabling the back button, you'll be a lot happier.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
It is sorta covered in the JavaRanch Style Guide.
subject: Browser Back Button