View Full Version : Need Help With A "Close" Button

04-07-2005, 05:03 PM
I have a simple page that for some reason I can't get the JS "close" button to work in Mozilla, but works fine in other browsers (IE, NS "older version"). I have tried several (all vairations I could find posted on the issue) on the button but still with the same result. I have even tried setting it as a link instead but with the same results.

When I use the javascript console in Mozilla I get the warning:
"Scripts may not close windows that were not opened by script."

Is there something wrong with my js code, or is there a known Moz. issue I haven't been made aware of?

Oh ya I have just recently upgraded to Mozzilla 1.7.5 from an older NS (which the close buttons worked just fine) so I am fairly new to Mozilla's quarkes.





<input type="button" value="Close1" onclick="window.close()"><BR>
<input type="button" value="Close2" onclick="window.close();"><BR>
<input type="button" value="Close3" onclick="javascript:window.close()"><BR>
<input type="button" value="Close4" onclick="javascript:window.close();"><BR>
<input type="button" value="Close5" onclick="self.close()"><BR>
<input type="button" value="Close6" onclick="self.close();"><BR>
<input type="button" value="Close7" onclick="javascript:self.close();"><BR>



Any help or suggestions would be greatly appreciated.

04-07-2005, 05:15 PM
It will work, except that you have to modify your statup prefs (in the folder pref, file "firefox.js" or "mozilla.js", and add:

pref("dom.allow_scripts_to_close_windows", true);

to the "// Scripts & Windows prefs" section.

Restart Mozilla or FF, and then it will accept the "close()" event and its variations.

04-07-2005, 05:46 PM
Thanks rlemon. :thumbsup:

It works now.

So is that option burried somewhere in the "preferences" menu? Or do you need to just know what to modify.

04-07-2005, 05:58 PM
So is that option burried somewhere in the "preferences" menu? Or do you need to just know what to modify.

no, it's in a JS file which Moz uses to configure itself. nb: you only change your own browser's preferenes, not those of the users who frequent your site.

04-07-2005, 06:00 PM
I'm looking into signing JS so this will work (i need to sign JS so i can allow the clipboard commands)

look into my previous thread "signing JavaScript" in the JavaScript SS forum.