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");
}
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>