Javascript Browser Window top Property

Description

Javascript Browser Window top Property

View in separate window

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {/*  w  ww  . j a  v a 2 s.  c o  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>

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




PreviousNext

Related