screenX只讀屬性返回從用戶瀏覽器窗口的左邊框到屏幕左側的水平距離(以像素為單位)。
screenX屬性是較新的screenLeft屬性的別名。
window.screenX
var win = window.open("", "popupWindow"); win.document.write("<p>This is 'popupWindow'"); win.document.write("<br>ScreenX: " + win.screenX); win.document.write("<br>ScreenY: " + win.screenY + "</p>");測試看看?/?
注意: screenX和screenY屬性等于screenLeft和screenTop屬性。
所有瀏覽器完全支持screenX屬性:
屬性 | ![]() | ![]() | ![]() | ![]() | ![]() |
screenX | 是 | 是 | 是 | 是 | 是 |
返回值: | 此數字等于從瀏覽器視口的左邊緣到屏幕左邊緣的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>ScreenX: " + win.screenX); win.document.write("<br>ScreenY: " + win.screenY + "</p>");測試看看?/?
窗口(Window)參考:window.screenY屬性
窗口(Window)參考:window.screenTop屬性
窗口(Window)參考:window.screenLeft屬性