使用javascript/html关闭窗口

使用javascript/html关闭窗口,javascript,html,Javascript,Html,我无法用javascript关闭chrome窗口。我读过它,因为它也需要用javascript打开,但必须有一个简单的方法来解决这个问题。我错过了什么 <html> <head> <script> function close_window() { close(); } </script> </head> <body

我无法用javascript关闭chrome窗口。我读过它,因为它也需要用javascript打开,但必须有一个简单的方法来解决这个问题。我错过了什么

<html>
    <head>
        <script>
        function close_window() {

            close();

        }
        </script>
    </head>
    <body>

    <a href="javascript:close_window();">close</a>
    </body>
</html>

函数关闭_窗口(){
close();
}

您无法关闭未打开的窗口,出于安全原因,浏览器不允许您关闭。没有解决方法。

您无法关闭未打开的窗口,出于安全原因,浏览器不允许您关闭。没有解决方法。

不,您只能关闭使用
窗口打开的内容。打开


或者如果你因为内存泄漏或其他原因关闭了浏览器。(笑话)

不,你只能关闭你用
窗口打开的东西。打开

或者如果你因为内存泄漏或其他原因关闭了浏览器。(笑话)

参见。使用open()打开新窗口,使用close()关闭新窗口:

function openWin() {
    myWindow = window.open("", "myWindow", "width=200, height=100");    // Opens a new window
}

function closeWin() {
    myWindow.close();                                                  // Closes the new window
}
看。使用open()打开新窗口,使用close()关闭新窗口:

function openWin() {
    myWindow = window.open("", "myWindow", "width=200, height=100");    // Opens a new window
}

function closeWin() {
    myWindow.close();                                                  // Closes the new window
}

在chrome中,无法关闭未使用javascript打开的网页。但是,如果您可以选择firefox和internet explorer的某些版本,这是可能的

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

在chrome中,无法关闭未使用javascript打开的网页。但是,如果您可以选择firefox和internet explorer的某些版本,这是可能的

 window.open('','_self').close();
可能的重复可能的重复