今天脚本了里写了一句话:windows
window.close()
可是浏览器却报了警告提示:Scripts may close only the windows that were opened by it
,并且也没有可以关闭我想关闭的页面,怎么办呢?找万能的度娘,搜到的解决方案有:浏览器
(1) spa
window.open('','_self','');
code
window.close();
ip
(2)it
open(location, '_self').close();
io
这两种我都试过了,仍是同样有警告信息,而且没法关闭窗口。
最后一种方案是:class
window.location.href="about:blank"; window.close();
终于成功关闭窗口啦!脚本