• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

To Disable Back button in all the browsers

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently i'm using the following code to disable the back button in my jsp page, but it works fine only in IE.

<script type="text/javascript">
histroy.forward(1);
</script>

Can anyone give the code to disable the back button in all browsers like opers, firefox, chrome etc..
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to heed http://faq.javaranch.com/java/InterfaceDesignersRule1.

Which brings up the question: why do you want to do this?
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf
The link is very usefull.
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey,

whilst you cannot disable the browser back buttons, you can add onbeforeunload event which will allow you to add functionality before the page is left.

I used this to add a confirmation box to notify users that leaving the page would lose any unsaved changes.

Note though that you cannot attach this to just the back button, and whenever the user tries to leave the page via a link/forward/back/reload, they would get the message.

Sean
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guessing you have a typo in your code above since histroy is misspelled.

If you use proper headers and posts, you can expire a page when the back button is pressed.

Eric
 
I once met a man from Nantucket. He had a tiny ad
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic