zoukankan      html  css  js  c++  java
  • 禁用浏览器的返回按钮

    1. 方法一: 超好用, 收藏

    <script language="javascript">
      //防止页面后退, 目前仅适用于chrome,Firefox,360极速模式
      history.pushState(null, null, document.URL);
      if (window.addEventListener) {
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
          history.pushState(null, null, document.URL);
          scrollTo(0,0);
        });
      } else if (window.attachEvent) {
        window.attachEvent('onpopstate', function () {
          history.pushState(null, null, document.URL);
          scrollTo(0,0);
        });
      }
    </script>

    2. 方法二: url没有变但是页面还会刷新

    <script language="JavaScript"> 
        javascript:window.history.forward(1); 
    </script>
  • 相关阅读:
    两种方法生成随机字符串
    cmd命令总结
    NOI前乱写
    多校模拟9
    字符串 口胡
    HEOI2020游记
    省选模拟104
    省选模拟103
    省选模拟102
    省选模拟101
  • 原文地址:https://www.cnblogs.com/floraCnblogs/p/disabled_brower_back_btn.html
Copyright © 2011-2022 走看看