-8

This is my code:

   function closewindow() {
        alert("This will close the window");
        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
        window.open('http://localhost/Authenticate/WebForm1.aspx','_self','');           
        window.close();
        return false;
    }

Works fine in IE, but not in Firefox and chrome.

In Firefox when dom.allow_scripts_to_close_window is set to true manually in about:config it works fine.

Tell how to set dom.allow_scripts_to_close_window in javascript OR Is their any other way to do this.

  • -1: There are tons of duplicates on the site. I remember reading a few of them. Short answer: it is not possible. (From a security standpoint, this is brilliant; from a developer standpoint, not so much). – Danny Beckett Apr 30 '13 at 06:27

1 Answers1

0

proper browser security only allows script to close windows opened by that script. IE has a security hole that can be used to circumvent this (open self), but other browsers don't. hopefully IE will patch this hole.

you can not, not even with IE (well you can if your site is trusted and security is turned low enough) change security setting via script.

Anil
  • 1,028
  • 9
  • 20