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

来源:互联网 发布:golang java 性能对比 编辑:程序博客网 时间:2024/06/05 12:42

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.


0 0
原创粉丝点击