其他分享
首页 > 其他分享> > js实现禁止浏览器后退

js实现禁止浏览器后退

作者:互联网

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

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

 

标签:document,浏览器,后退,js,URL,pushState,null,history
来源: https://www.cnblogs.com/shenjingwa/p/15028248.html