window.close(), self.close() not working on mozilla firefox

前端 未结 6 1927
无人及你
无人及你 2020-11-30 10:19

I want to close window on logout. I have used

  • window.close(),
  • self.close(),
  • var win = window.open(\"\",\"_s
相关标签:
6条回答
  • 2020-11-30 10:44

    Working 100 % for me

    In Mozilla by default the "dom.allow_scripts_to_close_windows" value which controls the Java Script close window is set to "false". In order to fix this issue change this value to "true"

    Location of the File:

    C:\Program Files\Mozilla Firefox\greprefs\all.js

    change "dom.allow_scripts_to_close_windows" from "false" to "true"

    Example:

    Default value

    pref("dom.allow_scripts_to_close_windows", false);

    Change it to:

    pref("dom.allow_scripts_to_close_windows", true);

    2.Close Mozilla browser

    3.Try accessing HTML page which has window.close() code snippet

    Note : If you not find "all.js" then go to C:\Program Files (x86)\Mozilla Firefox\defaults\pref\channel-prefs.js and add "pref("dom.allow_scripts_to_close_windows", true);" into "channel-prefs.js" file

    0 讨论(0)
  • 2020-11-30 10:49

    Is seems that they are working on Chrome Kiosk ( Fullscreen ) mode. Tried successfully. Up to 19 as of now.

    0 讨论(0)
  • 2020-11-30 10:52

    I have found that Firefox can only use window.close() when script has been called to open that window in the first place.

    Read here for more info.

    So if you didn't use a script to open that window, it can't be done.

    0 讨论(0)
  • 2020-11-30 11:01

    I tried to review all topics about window.close() and have found that: IE/Chrome/Safari(?) accept closure if we open something on _self, so generally

    top.open('','_self',''); top.close();

    does the work. FF (r 19 when writing this) is more strict about this and somehow forbids any probe like above. The good answer was found in related thread, that user must manually allow FF to have solution above working

    about.config -> dom.allow_scripts_to_close_windows = true;

    I was quite desperated, as Customer requested window closure on completed operation.

    Big bravo to FF dev team. This is exactly how it should work; pity only is that is hard to find it.

    Pawel.

    0 讨论(0)
  • 2020-11-30 11:07

    This worked for me perfectly:

    <a href="javascript:window.open('','_parent','');window.close();">Close this window</a>
    
    0 讨论(0)
  • 2020-11-30 11:10

    Ive been using something like this:

    <head>
    <script language="javascript" >
    function ffffd() {
    
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
    
    window.open('http://www.google.com','mywindow','width=400,height=200');
    window.close();
    }
    </script> 
    </head>
    <body>
    <input type= "button" name="new" value="New Window" onClick="ffffd()">
    </body>
    
    0 讨论(0)
提交回复
热议问题