English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Window screenLeft Property

JavaScript Window Object

screenLeftRead-only property that returns the horizontal distance (in pixels) from the left edge of the user's browser window to the left edge of the screen.

The screenLeft property is an old versionscreenXAlias of the property.

Syntax:

window.screenLeft
var win = window.open("", "popupWindow");
win.document.write("<p>This is #3939;
win.document.write("<br>ScreenLeft: " + win.screenLeft);
win.document.write("<br>ScreenTop: " + win.screenTop + "</p>);
Test and See‹/›

Note: The screenLeft and screenTop properties are equal to the screenX and screenY properties.

Browser compatibility

The numbers in the table specify the first browser version that fully supports the screenLeft property:

Property
screenLeftIs64IsIs9

Technical details

Return value:This number is equal to the number of CSS pixels from the left edge of the browser viewport to the left edge of the screen

More examples

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

var win = window.open("", "popupWindow", "left=500, top=350, width=300, height=200");
win.document.write("<p>This is #3939;
win.document.write("<br>ScreenLeft: " + win.screenLeft);
win.document.write("<br>ScreenTop: " + win.screenTop + "</p>);
Test and See‹/›

Cross-browser solution (for IE8and earlier versions, use screenX and screenY):

var win = window.open("", "popupWindow", "left=500, top=350, width=300, height=200");
/* If the browser does not support screenLeft and screenTop, screenX and screenY can be used instead */
if (!window.screenLeft) {}}
   window.screenLeft = window.screenX;
   window.screenTop = window.screenY;
}
win.document.write("<p>This is #3939;
win.document.write("<br>ScreenLeft: " + win.screenLeft);
win.document.write("<br>ScreenTop: " + win.screenTop + "</p>);
Test and See‹/›

Related References

Reference: Window (Window)window.screenTop property

Reference: Window (Window)window.screenX property

Reference: Window (Window)window.screenY property

JavaScript Window Object