Chrome下关闭浏览器,关闭非脚本打开的页面

今天脚本了里写了一句话:

window.close()

但是浏览器却报了警告提示:Scripts may close only the windows that were opened by it,而且也没有能够关闭我想关闭的页面,怎么办呢?找万能的度娘,搜到的解决方案有:

(1) 

  window.open('','_self','');

  window.close();

(2)

  open(location, '_self').close();

这两种我都试过了,还是一样有警告信息,并且无法关闭窗口。
最后一种方案是:

  window.location.href="about:blank";
  window.close();

终于成功关闭窗口啦!

原文地址:https://www.cnblogs.com/cocoqi/p/7874627.html