Prev Demo
JavaScript
>
Closed Property
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Closed Property examples.</h1> <p>Click the below buttons to know the closed property testing result.</p> <input type="button" value="Click to open" onclick="testOpen()"/><br /> <input type="button" value="Click to close" onclick="testClose()"/><br /><br /> <input type="button" value="Click to check" onclick="testCheck()"/><br /> <p id="myId"></p> <script> var newWindow; function testOpen() { newWindow = window.open("", "newWindow", "height=250, width=500"); } function testClose() { if (newWindow) { newWindow.close(); } } function testCheck() { if (!newWindow) { document.getElementById("myId").innerHTML = "Window is not yet opened!"; } else { if (!newWindow.closed) { document.getElementById("myId").innerHTML = "Window is not closed."; } else { document.getElementById("myId").innerHTML = "Window is closed" } } } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output