繁体   English   中英

如何禁用浏览器中的后退按钮?

[英]how to disable the back button in my browser?

我想在我的网页中禁用后退按钮...列出我可以执行此操作的方法...`

   if($data->num_rows > 0){
       while($row = $data->fetch_assoc()){

         header('Location:../cashier.php');
       }
   }else{
       echo "Username and  Password is Incorrect...Try  Again";
   }

} ?>`

这里有一些代码在除 IE9 及更低版本之外的所有浏览器上对我来说都非常有效。 (每次执行两次 pushState 是矫枉过正,但我​​还是喜欢它。)您只需要修改显示“myCritera, myStuff”等的代码。

$(document).ready(function() {
    if (myCriteria == 'yes') {
        window.addEventListener('popstate', function(event) {
            if (event.state) {
                if (window.history.state == null){
                    return;
                }
                $('#myStuff').hide();
                $('#myStuff2').hide();
                $('#otherStuff').show();
                window.history.pushState({},'', '');
                window.history.pushState({},'', '');
            }
        }, false);

        window.history.pushState({},'', '');
        window.history.pushState({},'', '');
    }
});

这是我的代码,效果很好:

 var url = window.history.forward();
 window.history.go(-window.history.length);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM