Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Setting in a tall corn field in Indiana
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help With A "Close" Button

    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.

    Code:
     
    
    <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.

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Oct 2002
    Location
    Setting in a tall corn field in Indiana
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks rlemon.

    It works now.

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

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by caclark
    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.
    *keep it simple (TM)

  • #5
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •