Window self Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window self

Description

The self property returns the current window.

This property is read-only.

Return Value

A reference to the Window object itself

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {/*from  w  w w . j av  a  2  s . co m*/
    if (window.top != window.self)  {
        document.getElementById("demo").innerHTML = "This window is not the topmost window! Am I in a frame?";
    } else {
        document.getElementById("demo").innerHTML = "This window is the topmost window!";
    }
}
</script>
</head>
<body>

<button onclick="myFunction()">Check window</button>

<p id="demo"></p>

</body>
</html>

Related Tutorials