简体   繁体   中英

How to close the window on the latest version of Mozilla Firefox?

I am currently using Mozilla Firefox 30.0 and it seems that it doesn't support window.close() anymore.

You may refer on the image below or if it is too small for you, here is the link .

这是我的例子

I opened the website of Google using window.open and then I tried to close it using window.close() but it says undefined .

Is there any other option that I can using to close the window using javascript on firefox?

The Firebug console unfortunately does not display the warning that goes along with it, which reads (in the regular Firefox Web Console}:

Scripts may not close windows that were not opened by script.

Also MDN window.close states:

This method is only allowed to be called for windows that were opened by a script using the window.open method.

So, you aren't allowed to call window.close() on windows that were explicitly opened by the user.

PS: This isn't new behavior, but around for ages (even before Firefox was called Firefox).

PS: To give an example, you are allowed to do something like this, only, ie close a window returned from window.open :

var w = window.open("http://google.com");
setTimeout(function() { w.close(); }, 1000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM