Why is the window.close() works in IE browser but not FireFox? "Warning: Scripts may not close windo

Firefox has an issue with you trying to close a window that wasn't opened by a script.

Here is the error that I pulled out of the FireFox error console.

"Warning: Scripts may not close windows that were not opened by script."

 

Seems like an extra security measure on FireFox's part.


Hi boston_ma,

Just as what you said, the reason why the code 'window.close();' doesn't work in FireFox is caused by the security setting in the browser. And to deal with the issue, we need to open the professional config page in the FireFox and change the option in it.

Here are the steps you can follow by to set this security option in FireFox.

  1. Open a blank page and type "about:config" in the Url text box. Here, you will receive a warning message, just click the button to continue.

     

  2. Find the "dom.allow_scripts_to_close_windows" item in the list and doulbe click it to make the value be equal to 'true'. (You can enter 'allow' in the filter box to get the item more quickly)

     

Then, you can use 'window.close();' to close the window in FireFox now.


发布了430 篇原创文章 · 获赞 415 · 访问量 925万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览