This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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.
I agree. Here's the link:
subject: Browser Back Button
jQuery in Action, 3rd edition