Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to disable back button of the browser using javascrpt

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 322
    Comment on it

    There are many cases where we have to disable the back button of the browser.

    Here, the following code will help you to make your back button disable.

    HTML:

    <body onload="disableBackOnLoad(); ">
    Now the back button is disabled
    </body>

     

     

    SCRIPT:

    function disableBackOnLoad () {
         window.location.href += "#";
         setTimeout("changingUrl()", "50"); 
    }
    
    function changingUrl() {
      window.location.href += "1";
    }
    // If you want to skip the auto-positioning at the top of browser window,you can add the below code:
    window.location.hash=' ';
    var storedHash = window.location.hash;
    window.setInterval(function () {
        if (window.location.hash != storedHash) {
             window.location.hash = storedHash;
        }
    }, 50);
    

     

    This will help you to disable your browser's back button.

    Tested in all major browsers including IE. Demo attached please have a look!

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: