mark vanzuela
mark vanzuela

Reputation: 1391

window.close() doesn't work on Firefox, any work around?

I am trying to close a window using window.close() but this works on IE only but not on Firefox. Has anyone encountered this one and any work around?

Thanks...

Upvotes: 3

Views: 16253

Answers (4)

Stucco
Stucco

Reputation: 420

window.close(); worked for me (FF 31.5.0). However, in order for me to get it to work I had to change the advanced settings:

about:config -> dom.allow_scripts_to_close_windows = true;

Upvotes: 2

techzen
techzen

Reputation: 2955

This is a security feature added in FF. You can see that this has been deliberately not allowed from Mozilla site docs.

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

Upvotes: 2

paxdiablo
paxdiablo

Reputation: 881213

Did your script open the window? Firefox 2 and later do not allow scripts to close windows that they did not open.

You could try this trick, but I have no idea whether it will work. I live on the side of the population that believes users should be in control of their browser windows, not applications (despite the fact you may have a good reason for this).

Upvotes: 7

vpram86
vpram86

Reputation: 6000

I had the same problem and used this recently. Hope it helps.

Upvotes: 3

Related Questions