Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Browser Back Button

 
shekarasankaran
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i disable the back button of browser through javascript
 
James Hobson
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
James
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Dave.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sshekar",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
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.
Thanks.
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic