English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
screenTopRead-only property that returns the vertical distance (in pixels) from the top border of the user's browser viewport to the top of the screen.
The screenTop property is an oldscreenYAlias of the property.
window.screenTop
var win = window.open("", "popupWindow"); win.document.write("<p>This is 'popupWindow'); 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.
The numbers in the table specify the first browser version that fully supports the screenTop property:
Property | |||||
screenTop | Is | 64 | Is | Is | 9 |
Return value: | Number of CSS pixels from the top edge of the browser viewport to the top of the screen |
---|
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 'popupWindow'); 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 'popupWindow'); win.document.write("<br>ScreenLeft: " + win.screenLeft); win.document.write("<br>ScreenTop: " + win.screenTop + "</p>Test and See‹/›
Reference: Window (Window)window.screenLeft property
Reference: Window (Window)window.screenX property
Reference: Window (Window)window.screenY property