首页 > 技术文章 > 禁止浏览器返回登入页面

ldlx-mars 2018-07-09 16:54 原文

目前很多项目都没有特意做这个处理,就是浏览器返回到登入页面,然后点击下一页箭头,可以进入,但是如果有这个需求只需要在禁止的那个页面,输入如下代码即可

<script>
        $(document).ready(function (e) {
            var counter = 0;
            if (window.history && window.history.pushState) {
                $(window).on('popstate', function () {
                    window.history.pushState('forward', null, '#');
                    window.history.forward(1);
                    // alert("不可回退");  //如果需在弹框就有它
                    self.location="index.html?v="+version; //如查需要跳转页面就用它
                });
            }
     
            window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
            window.history.forward(1);
        });
    </script>  

 附加一个FQ软件:https://my.ishadowx.net/#

推荐阅读