编辑下面的代码:【加编码】
<html> <head> <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="'myWindow' has never been opened!"; } else { if (myWindow.closed) { document.getElementById("msg").innerHTML="'myWindow' has been closed!"; } else { document.getElementById("msg").innerHTML="'myWindow' has not been closed!"; } } } </script> </head> <body> <input type="button" value="Open 'myWindow'" onclick="openWin()"> <input type="button" value="Close 'myWindow'" onclick="closeWin()"> <br><br> <input type="button" value="Has 'myWindow' been closed?" onclick="checkWin()"> <br><br> <div id="msg"></div> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂