Window screenLeftandscreenTopProperty

Window 对象参考手册Window Object

Definition and Usage

The screenLeft and screenTop properties return the X and Y coordinates of the window relative to the screen.

Syntax

window.screenLeft
window.screenTop


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the screenLeft and screenTop properties, except Firefox.

Note:For Firefox, please use "window.screenX" and "window.screenY"。


Example

Example

Return the X and Y coordinates of the new window relative to the screen:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Example Tutorial (example.com)</title> <script>
function openWin(){ myWindow=window.open('',''); myWindow.document.write("<p>This is 'My Window'"); myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft); myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>"); }
</script> </head> <body> <input type="button" value="Open 'My Window'" onclick="openWin()"> </body> </html>

Try it yourself »


Window 对象参考手册Window Object Other Extensions