当前位置:主页 > 网页前端 > JavaScript代码 >

js禁止浏览器页面后退功能的实例(推荐)

时间:2021-04-25 10:12:29 | 栏目:JavaScript代码 | 点击:

实例如下所示:

<script>
 $(function(){
   if(window.location.href.indexOf("/login") > -1) {
    //防止页面后退
     history.pushState(null, null, document.URL);
     window.addEventListener('popstate', function () {
      history.pushState(null, null, document.URL);
     });
   }
 });
</script>

您可能感兴趣的文章:

相关文章