shake demo

Click to shake the box.

Friday, 21 November 2014

Disable Browser Back Button

// Add below js code on master page or any .js file
<%-- Code for browswer back button disable start from here --%>
   
    <script type="text/javascript" language="javascript">

        function changeHashOnLoad() {
            window.location.href += '#';
            setTimeout('changeHashAgain()', '50');
        } 12438.00

        function changeHashAgain() {
            window.location.href += '1';
        }

        var storedHash = window.location.hash;
        window.setInterval(function () {
            //          if (window.location.hash != storedHash) {
            window.onhashchange = function () { window.location.hash = storedHash; }
            window.location.hash = storedHash;

        }, 50);
        window.onload = changeHashOnLoad;
        window.location.hash = "no-back-button";
        window.location.hash = "Again-no-back-button"; //for google chrome
        // window.onhashchange = function () { window.location.hash = "no-back-button"; }
        window.history.forward(1);
        history.go(1);
    </script>
    <%-- end Code for browswer back button disable --%>

No comments:

Post a Comment