Window top Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window top


The top property returns the topmost browser window of the current window.

This property is read-only.

Return Value

A reference to the topmost window in the window hierarchy

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
function myFunction() {//from w  w  w  .  j a  va2s .  c  o  m
    if ( != 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!";

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

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


Related Tutorials