...

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



caclark
04-07-2005, 04: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.




<html>
<head>
<title>Untitled</title>

</head>

<body>

<form>

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


</form>

</body>
</html>



Any help or suggestions would be greatly appreciated.

rlemon
04-07-2005, 04: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.

caclark
04-07-2005, 04: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.

jbot
04-07-2005, 04: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.

rlemon
04-07-2005, 05: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum