Disable browser "Back" button

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?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you think this is a good functionality to implement, you've got some very strange ideas.
No, you will need to use a child window for this. and disable toolbars,etc in it.

skunduAuthor Commented:
Some commercial web pages does not let you go back to previous page (leaving their web site). How do they do that? By some way but not the javascript?

Ensure Business Longevity with As-A-Service

Using the as-a-service approach for your business model allows you to grow your revenue stream with new practice areas, without forcing you to part ways with existing clients just because they don’t fit the mold of your new service offerings.

Saqib KhanSenior DeveloperCommented:
<body onLoad="history.go(+1)">

put it on the page where you dont want it to Go.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
<a href="somwhere.asp" onclick="location.replace(this.href);return false;">TEST</a>

location.replace will not let you go back to the original page.
You said ...
"Some commercial web pages does not let you go back to previous page (leaving their web site). How do they do that? By some way but not the javascript?"

A way to do that without javascript is to use a meta refresh tag in the entry page to your site.  If you have a banner ad or a link to you from another site you can prevent the user from going back (leaving your site). Put the following meta tag in the <head></head> section of your page to redirect to page2.html after 0 seconds.

<meta http-equiv=refresh content="0, URL=page2.html">

You could put this in your home page and make page2.html your home page content.

Saqib KhanSenior DeveloperCommented:
guenze u ok buddy:). Question is been answered already.
wow that's a terrible user experience!!!
how about using a document.location.replace() instead? then the page will be removed from the history otherwise the user will click back and end up on the page they started on (not very nice).  
simply use this code in head tag u will block user to go back through back button :) so simple it is

<script language="javascript">
This code is useful in following conditions.

1)  When you dont want the round trip to server
2)  When the page contents contains dynamically created  objects. ( u will loose all the stuff u entered after refresh)

code follows

 var gotBodyFocus=0; // used in gotBFocus() function.

function escBackSpace() // called on document.body keydown event
    if(event.keyCode == 8)
          if  (gotBodyFocus == 1 | document.activeElement.getAttribute("type") != "text") // to avoid the backspace event except the Textbox
             //event.keyCode = 0;

function gotBfocus() //called on document.body onfocus event
  gotBodyFocus = 1;

function lostBfocus() // called on document.body onblur event
  gotBodyFocus = 0;

<body MS_POSITIONING="GridLayout" onkeydown="escBackSpace();" onblur="lostBfocus();" onfocus="gotBfocus();">
        <form id="Form1" method="post" runat="server" onkeydown="escBackSpace();" onblur="lostBfocus();">
Saqib KhanSenior DeveloperCommented:
above Solution by vac is Strictly for IE, I would not use it in my application
You may try the following options from JavaScript,

1. If you move from page1 -> page2, and want to disable the browser back in page 2,then add the following at the top of page1.

if(window.history.forward(1) != null)
This works for both IE and NS

2.You may also replace the page in the history with the current page itself so that there is no page to go back.
                  location.replace(this) would do this.

3.If you are using JSP and not HTML, the best thing would be to prevent the JSP page from caching itself.

Bolter99Design EngineerCommented:
Theres another way you can do it.
Simply hide the back button and use a javascript to cancel out the Backspace button on the keyboard.

function KeyCache() {
  if (window.event && window.event.keyCode == 8) {
    window.event.keyCode = 123; //Replaces with F12 button. (Does nothing in IE)
An alternative is

Put this anywhere on the page you dont want to go back to.
We need a better solution.  Here's a new scenario.  I have a form that that I send to the user and I put different parts of the form in <Div></Div> pairs that I wrap around different parts of the form.  I set the div attributes to hidden and only make visible the portion of the form that I want the user to fill in.  Based on that input, I will hide the portion of the form they just completed and either show a new portion of the form or submit the form for processing.  I need to keep the user from going back within that page so that I can properly manage the visiblity of the different parts of the form until the form is sent to the server for final process, after which I can return control of the browser back to them.  Any creative solutions to this one?
well there seem to be a litle confusion about cache and history, i can disable cache and still be able to navigate back using several processes, even if cache of that page is disabled that means only that the page will be refreshed from the server, it solves most of the cases. But sometimes we dont want the history back thing.. well it seems wiser to me to prevent the url from entering the history list (this can be done sometimes using a location.replace) than catching all atempts to navigate back in history list. Of course this wont be good for everyone, in my case i dont mind user goes back to some other site but dont want to allow the resubmition/refresh of my page because it is not stateless the content displayed is always in conformity with the server stored state, meaning that going back and requesting some other thing from that page will bring confusion because the server responds only to the stored state (normal site and app's work on a stateless schema, all info needed to make an operation is submitted. not my case)
I did this unintentionally before on a shopping cart page for a commercial website I developed and we actually lost (at least one) customer because of it...

Add this to the bottom of your page:

window.onbeforeunload = function () {
   // Disable back.

This works on IE, Firefox and Safari. Its used to give warnings when people leave your page, by any means, except for forms and links. Like closing the window or pressing then back button.
As a side effect the browser stops caching previous pages, if you press back you just return to the same page. We have been using this technique in a browser game, so that you dont get session and sql errors, cause people change pages and cookie and then return to a older view. ( see http://booty.game-host.org/ for an example.)

For more info:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.