The self
property returns the current window.
self |
Yes | Yes | Yes | Yes | Yes |
window.self
A reference to the window object itself.
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {<!--from ww w . ja va 2 s . c om-->
if (window.top!=window.self) {
console.log("This window is not the topmost window!");
} else {
console.log("This window is the topmost window!");
}
}
</script>
</head>
<body>
<button onclick="myFunction()">Check window</button>
</body>
</html>
The code above is rendered as follows: