Javascript - window.close、self.close、parent.close、none 用于关闭 window、Google 中的选项卡 Chrome

Javascript - window.close, self.close, parent.close, none works to close window, tab in Google Chrome

失败:

代码:

<script>
function callKiller() {
  window.close();
  self.close();
  parent.close();

  setTimeout(function() { 
    try { 
      window.close(); 
      self.close(); 
      parent.close()
    }catch(e) {
      console.log(e, 'idiot browsers, why you cant kill it you idiot'); 
    } 
  }, 10000);
}
</script>

<!--

  Plugin:

    - Detect iOS?, Android !Chrome
    - Safari?
    - IE or IE EDGE??? 

  Then close the window, Cause no service cant be offered                          
-->
<body onLoad=callKiller(); >
  Sorry, we cant offer you any service. 
    Safari do not have WebRTC and they wont have it anytime sooner. 
    IE Edge do not have WebRTC. Its ORTC not WebRTC. 
    Read the Wiki
    iOS we have no time, for you to write everything in Objective-C, go learn yourself Objective-C

这是 chrome 很久以前安装的安全功能。

为了使用 window.close() 函数:

The close() method on Window objects should, if all the following conditions are met, close the browsing context A:

  • The corresponding browsing context A is script-closable.

  • The browsing context of the incumbent script is familiar with the browsing context A

  • The browsing context of the incumbent script is allowed to navigate the browsing context A.

A browsing context is script-closable if it is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), or if it is a browsing context whose session history contains only one Document.

所以您基本上不能使用 javascript 关闭页面中 javascript 未打开的 window。

阅读更多here.

我的建议是将您的访问者重定向到另一个页面。