screenLeft property (window)
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.
- To get the vertical position of the top side of the browser's client area, use the screenTop property.
- If you need the size of the client area, use the clientWidth and clientHeight properties of the html element.
- To get the size and the top-left corner of the browser window, use the outerWidth, outerHeight and the screenX, screenY properties.
If you need information about the dimensions of the screen, use the screen object.
Syntax:
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?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments