<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script>
var myWindow;
function openWin(){
myWindow=window.open("","","width=400,height=200");
}
function closeWin(){
if (myWindow){
myWindow.close();
}
}
function checkWin(){
if (!myWindow){
document.getElementById("msg").innerHTML="我的窗口没有被打开!";
}
else{
if (myWindow.closed){
document.getElementById("msg").innerHTML="我的窗口被关闭!";
}
else{
document.getElementById("msg").innerHTML="我的窗口没有被关闭!";
}
}
}
</script>
</head>
<body>

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

</body>
</html>

posted on 2017-02-24 16:30  仔仔爱学习  阅读(5270)  评论(0编辑  收藏  举报