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

screenLeft property (window)

Browser support:
Returns an integer value that indicates the horizontal position of the left side of the browser's client area, relative to the left side of the screen.
This property retrieves the horizontal position of the left side of the browser window instead of the browser's client area in Google Chrome and Safari. There is no property or method in JavaScript to get the position of the top-left corner of the client area in Firefox, Google Chrome and Safari. 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.screenLeft;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

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

Example HTML code 1:

This example illustrates the use of the screenLeft 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