脚本不得关闭非脚本打开的窗口。Scripts may close only the windows that were opened by it


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

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();

终于成功关闭窗口啦!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM