js 关闭页面(Scripts may close only the windows that were opened by it.)
Posted 一米阳光!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js 关闭页面(Scripts may close only the windows that were opened by it.)相关的知识,希望对你有一定的参考价值。
传送http://blog.csdn.net/kuangfengbuyi/article/details/52052301
js关闭当前页面,当该页面不是其他页面打开的,而是直接输入url,
直接用window.close()无法关闭。
以下代码可以实现不同浏览器的关闭操作:
function closewin(){ if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") !=-1) { window.location.href="about:blank"; window.close(); } else { window.opener = null; window.open("", "_self"); window.close(); } }
location对象
function currLocation() { alert(window.location) } function newLocation() { window.location="/index.html" }
以上是关于js 关闭页面(Scripts may close only the windows that were opened by it.)的主要内容,如果未能解决你的问题,请参考以下文章