JS防止页面后退 - - SegmentFault 思否

402 阅读1分钟
原文链接: segmentfault.com

防止页面后退,包括 键盘、鼠标手势等产生的后退动作。

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


作者:小小书童
网站:apppay.xyz