JavaScript BOM 窗口屏幕(window.screen)
-
window.screen
window.screen对象包含有关用户屏幕的信息。属性:- screen.width
- screen.height
- screen.availWidth
- screen.availHeight
- screen.colorDepth
- screen.pixelDepth
-
窗口屏幕宽度
screen.width属性返回访问者屏幕的宽度(以像素为单位)。以像素为单位显示屏幕宽度:
尝试一下document.getElementById("demo").innerHTML = "Screen Width: " + screen.width;
结果将是: -
窗口屏幕高度
screen.height属性返回访问者屏幕的高度(以像素为单位)。以像素为单位显示屏幕高度:
尝试一下document.getElementById("demo").innerHTML = "Screen Height: " + screen.height;
结果将是: