编辑这个页面须要登录或更高权限!
screenLeft只读属性返回从用户浏览器窗口的左边框到屏幕左侧的水平距离(以像素为单位)。
screenLeft属性是旧版screenX属性的别名。
window.screenLeft
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>");测试看看‹/›
注意: screenLeft和screenTop属性等于screenX和screenY属性。
表格中的数字指定了完全支持screenLeft属性的第一个浏览器版本:
属性 | |||||
screenLeft | 是 | 64 | 是 | 是 | 9 |
返回值: | 此数字等于从浏览器视口的左边缘到屏幕左边缘的CSS像素数 |
---|
返回相对于屏幕的新窗口的x和y坐标:
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>");测试看看‹/›
跨浏览器解决方案(对于IE8和更早版本,使用screenX和screenY):
var win = window.open("", "popupWindow", "left=500, top=350, width=300, height=200"); /* 如果浏览器不支持screenLeft和screenTop,可以使用screenX和screenY */ 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>");测试看看‹/›
窗口(Window)参考:window.screenTop属性
窗口(Window)参考:window.screenX属性
窗口(Window)参考:window.screenY属性