js实现禁止浏览器后退

试了网上不少的js禁止浏览器后退的代码,发现只有下面的一种效果还是可以的。

<script language="javascript">
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', function () {
        history.pushState(null, null, document.URL);
    });
</script>

 

posted @ 2021-07-18 23:16  神经蛙  阅读(975)  评论(0编辑  收藏  举报