You are here: Reference > JavaScript > client-side > browser > properties > screenY (window)

screenY property (window)

Browser support:
9
Returns an integer value that indicates the vertical position of the top side of the browser window, relative to the top side of the screen.
Note: The screenY property is supported in Internet Explorer from version 9.
The screenY property retrieves wrong value in Opera. There is no property or method in JavaScript to get the position of the top-left corner of the browser window in Opera and Internet Explorer before version 9.
If you need the position of the top side of the browser's client area, use the screenTop property.
The screenY and screenTop properties are equivalent in Google Chrome and Safari, they return the vertical position of the top side of the browser window.
  • To get the left position of the browser window, use the screenX property.
  • If you need the size of the browser window, see the pages for the outerHeight and outerWidth properties.
  • The browser window can be resized with the resizeBy and resizeTo methods,
  • and can be moved with the moveBy and moveTo methods.
If you need information about the dimensions of the screen, use the screen object.

Syntax:

object.screenY;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that represents the y-coordinate of the top side, in pixels.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the screenY property:
<head>
    <script type="text/javascript">
        function UpdatePos () {
            var message = "";
            if ('screenLeft' in window) {
                message += "Client area: " + window.screenLeft + "px, " + window.screenTop + "px<br/>";
            } 
            if ('screenX' in window) {
                message += "Browser window: " + window.screenX + "px, " + window.screenY + "px";
            }

            var info = document.getElementById ("info");
            info.innerHTML = message;
        }
    </script>
</head>
<body onload="UpdatePos ()">
    <b>Left, top positions:</b>
    <div id="info" style="height:65px; width:250px; background-color:#e0a0a0;"></div>
    <button onclick="UpdatePos ();">Update positions!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content