`

window.close()不起作用

阅读更多

js中使用window.close()关闭页面时,发现chrome和firefox不起作用且firefox没有任何提示,很烦人。而chrome会报“Scripts may close only the windows that were opened by it”。

 

解决办法:

1.针对firefox:

   firefox配置:地址栏输入about:config,修改属性“dom.allow_scripts_to_close_windows”为true;

2.针对chrome:

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics