0
  function CloseWindow()
  {
        window.close();
  }

The above code is working fine for IE but Firefox does not allows to close browsers window any solution???

Neo
  • 15,491
  • 59
  • 215
  • 405
  • http://csharpdotnetfreak.blogspot.com/2008/11/javascript-windowclose-does-not-work-in.html – Tim Schmelter Aug 18 '11 at 09:04
  • possible duplicate of [How can I close a window with Javascript on Mozilla Firefox 3?](http://stackoverflow.com/questions/760422/how-can-i-close-a-window-with-javascript-on-mozilla-firefox-3) – Tim Schmelter Aug 18 '11 at 09:05

3 Answers3

2

Try to use self object

<a href="javascript:self.close()">Close Window</a>
Amir Ismail
  • 3,865
  • 3
  • 20
  • 33
0

similar post answer

function closeWindow() {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
    alert("This will close the window");
    window.open('','_self');
    window.close();
}

closeWindow();

reason For security reasons, your script cannot close a window/tab that it did not open.

The solution is to present the age prompt at an earlier point in the navigation history. Then, you can choose to allow them to enter your site or not based on their input.

Instead of closing the page that presents the prompt, you can simply say, "Sorry", or perhaps redirect the user to their homepage.

Pratik
  • 30,639
  • 18
  • 84
  • 159
-1

Step 1 : Type the in address bar as " about:config " and press enter key

Step 2: "i'll be careful , I promise" Click on this button

Step 3: " dom.allow_scripts_to_close_windows;true " Search this line and Double click on it.

PsiX
  • 1,661
  • 1
  • 17
  • 35