On 22/10/2013 2:57 AM, Matthew Gertner wrote:
On Monday, October 21, 2013 5:45:44 PM UTC+2, Neil wrote:
Well, you could turn of that error; it's just a pref. Of course you
would then decide whether to trap all the other DOMWindowClosing events
to stop other random scripts from closing windows.

Alternatively, you could maybe looking into setting the window to have
an app docShell, in which case it's allowed to close itself.

I can't really change the user's prefs,

FWIW, recently a method nsIDOMWindowUtils::allowScriptsToClose() was added for this purpose - chrome code can call this to allow the window.close() to work without needing to change a pref.

The socialapi code has a couple of other tricks around this too - we call this method (so the code can call window.close()) but then we cancel the DOMWindowClose event so we can take some subtly different actions when window.close() is called - in our case, we just close a popup panel. The code is at http://mxr.mozilla.org/mozilla-central/source/toolkit/components/social/MozSocialAPI.jsm#224 if it helps.

Mark
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to