Javascript Browser Window screenX and screenY Property

Introduction

Return the x and y coordinates of the new window relative to the screen:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {// ww w  .j a v a  2 s .co m
  var myWindow = window.open("", "myWin");
  myWindow.document.write("<p>This is 'myWin'");
  myWindow.document.write("<br>ScreenX: " + myWindow.screenX);
  myWindow.document.write("<br>ScreenY: " + myWindow.screenY + "</p>");
}
</script>
</head>
<body>

<button onclick="myFunction()">Open "myWin"</button>

</body>
</html>

The screenX and screenY properties returns the x and y coordinates of the window relative to the screen.

The screenX and screenY properties returns a Number representing the horizontal and/or vertical distance of the window relative to the screen, in pixels.




PreviousNext

Related