SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>window-close</title>
	<script>
		var myWindow;
        <!-- 打开一个窗口 -->
        function openWin(){
            myWindow=window.open("","","width=400,height=400");
        }
        <!-- 关闭“mywindow”窗口 -->
        function closeWin(){
            if (myWindow){
                myWindow.close();
            }
        }
        <!-- 检查窗口是否关闭 -->
        //console.log();信息打印到控制台
        function checkWin(){
            if (!myWindow){
                 console.log("我的窗口没有被打开!");
            }
            else{
                if (myWindow.closed){
                     console.log("我的窗口被关闭!");
                }
                else{
                    console.log("我的窗口已打开!");
                }
            }	
        }
	</script>
</head>

<body>

<input type="button" value="打开我的窗口" onclick="openWin()" />
<br><br>
<input type="button" value="关闭我的窗口" onclick="closeWin()" />
<br><br>
<input type="button" value="我的窗口被关闭了吗?" onclick="checkWin()" />
<br><br>
<div id="msg"></div>
	
</body>
</html>