0

how can I disable the browser's "Back" button in a HTML page? I do not want to create JavaScript window to avoid showing any toolbar,etc. In regular HTML page, is there any way to disable the back button in the toolbar?

thanks

vascowhite
  • 18,120
  • 9
  • 61
  • 77
Brawia
  • 33
  • 1
  • 6
  • I don't know of a way to outright disable it, but you can prompt the user if they try to navigate away (for example, by pressing the back button) – Andy Hunt Aug 10 '11 at 13:14
  • 1
    -1 for wanting to interfere with the user's browsing experience. If they wan't to click the back button, they should be able to. – vascowhite Aug 10 '11 at 13:26
  • what the hell has php to do with this??? –  Aug 10 '11 at 13:59
  • Duplicated of http://stackoverflow.com/questions/87422/disabling-back-button-on-the-browser – Diego Oct 18 '11 at 11:58

3 Answers3

4

You can't technically disable it, and moreover you shouldn't. Disabling the back button of a browser would fundamentally change the browsing experience for a user which isn't your place to do.

If going back in the browser creates problems for your application then you should restructure your workflow so it doesn't. An example of this is implementing the POST/REDIRECT/GET pattern.

More Info: http://en.wikipedia.org/wiki/Post/Redirect/Get

Ira Rainey
  • 5,173
  • 2
  • 34
  • 42
0

There's no way to disable the Back-button using regular HTML as you specify.

Pål Brattberg
  • 4,568
  • 29
  • 40
-1

Write this code between script tags

    history.pushState(null, null, location.href);
    window.onpopstate = function () {
        history.go(1);
    };
Kenly
  • 24,317
  • 7
  • 44
  • 60