Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <script> var myWindow; function openWin() { myWindow = window.open("", "myWindow", "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> <button onclick="openWin()">Open "myWindow"</button> <button onclick="closeWin()">Close "myWindow"</button> <br><br> <button onclick="checkWin()">Has "myWindow" been closed?</button> <br><br> <div id="msg"></div> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_closed by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:27:47 GMT --> </html>
Result:
Try it Yourself - © w3schools.com