Window screenLeft和screenTop 属性

Window screenLeftscreenTop 属性

Window 对象参考手册 Window 对象

定义和用法

screenLeft和screenTop属性返回窗口相对于屏幕的X和Y坐标。

语法

window.screenLeft
window.screenTop

浏览器支持

Firefox

所有主流浏览器都支持screenLeft和screenTop属性,Firefox除外。

注意: Firefox 浏览器请使用 "window.screenX" and "window.screenY"。

实例

实例

返回新窗口相对于屏幕的X和Y坐标:


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>知识兔(zhishitu.com)</title>
<script>
function openWin(){ myWindow=window.open('',''); myWindow.document.write("<p>这是'我的窗口'"); myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft); myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>");}</script></head><body> <input type="button" value="打开 '我的窗口'" onclick="openWin()"> </body></html>
知识兔 »
Window 对象参考手册 Window 对象
计算机