How to close a window in firefox using javascript?

I use top.window.close () to close the parent window, but it does not work in Mozilla firefox. Please suggest alternatives. The above code works fine for IE6.

+3
source share
3 answers

From MDC :

This method is only allowed for windows opened with a script using the window.open method. If the window did not open the script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened using the script.

, , JavaScript target . , , , target="_blank", target="foo", ( Firefox 3.6.13).

, , /, , / ( , ).

+6

, Firefox, window.close, dom.allow_scripts_to_close_windows true about:config.

window.close 190515.

+1

This is what I use:

<head>
<script language="javascript" >
function ddd() {

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="ddd()">
</body>
0
source

Source: https://habr.com/ru/post/1782242/


All Articles