screenLeft
收藏:0
阅读:28
Window screenLeft 和 screenTop 属性
定义和用法
screenLeft和screenTop属性返回窗口相对于屏幕的X和Y坐标。
语法
window.screenLeft
window.screenTop
window.screenTop
浏览器支持
所有主要浏览器都支持pageXOffset和pageYOffset属性,Firefox除外。
注意: Firefox 浏览器请使用 "window.screenX" and "window.screenY"。
实例
返回新窗口相对于屏幕的X和Y坐标:
<html>
<head>
<script>
function openWin()
{
myWindow=window.open(‘‘,‘‘);
myWindow.document.write("<p>This is ‘myWindow‘");
myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft);
myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>");
}
</script>
</head>
<body>
<input type="button" value="Open ‘myWindow‘" onclick="openWin()">
</body>
</html>
<head>
<script>
function openWin()
{
myWindow=window.open(‘‘,‘‘);
myWindow.document.write("<p>This is ‘myWindow‘");
myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft);
myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>");
}
</script>
</head>
<body>
<input type="button" value="Open ‘myWindow‘" onclick="openWin()">
</body>
</html>