简体   繁体   English

如何禁用/限制浏览器重新加载/刷新功能?

[英]How to disable/restrict browser reload/refresh functionality?

Trying to do this, which is executing a default behaviour.尝试这样做,这是执行默认行为。

   window.addEventListener('beforeunload', this.beforeUnloadFunc);

   function beforeUnloadFunc(e) {
      e.preventDefault();
      e.returnValue = '';
      return null;         
   }

You may try this!你可以试试这个!

document.onkeydown = function() {
    if(event.keyCode == 116) {
            event.returnValue = false;
            event.keyCode = 0;
            return false;
           }
}

Source https://www.codeproject.com/Questions/243851/How-to-disable-back-forward-and-Refresh-functional来源https://www.codeproject.com/Questions/243851/How-to-disable-back-forward-and-Refresh-functional

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM