window.opener=null;
window.open('','_self');
window.close();使用上述js代码关闭Chrome窗口时弹出错误信息:Scripts may close only the windows that were opened by it
解决方法:
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();
}
}
已有 10174 位网友参与,快来吐槽:
发表评论