/

HTML / CSS / JavaScript Tutorial

JavaScript Window property: closed

[this page | pdf | back links]

The closed property (of the JavaScript BOM window object) returns true if the window has been closed or false if it has not been closed. If the window doesn’t exist (e.g. because it was never opened) then this can be tested for by e.g. evaluating (!windowvar) as this will evaluate to false if windowvar does not exist.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Window default closed: <b id="element"></b><br>

<script>
var x = window.closed;
document.getElementById("element").innerHTML = x;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile