js实现禁止浏览器后退

时间:2021-07-19 09:55:22   收藏:0   阅读:28

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

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

 

原文:https://www.cnblogs.com/shenjingwa/p/15028248.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!