width只读属性返回屏幕的总宽度(以像素为单位)。
使用height属性获取屏幕的总高度(以像素为单位)。
screen.width
var x = "Total Width: " + screen.width;测试看看‹/›
所有浏览器完全支持width属性:
属性 | |||||
width | 是 | 是 | 是 | 是 | 是 |
返回值: | 一个数字,表示用户屏幕的总宽度,以像素为单位 |
---|
此示例显示所有屏幕属性:
var txt = ""; txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>"; txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight +"</p>"; txt += "<p>Color depth: " + screen.colorDepth + "</p>"; txt += "<p>Color resolution: " + screen.pixelDepth + "</p>"; document.write(txt);测试看看‹/›
screen参考:screen.availHeight属性
screen参考:screen.availWidth属性
screen参考:screen.colorDepth属性
screen参考:screen.height属性
screen参考:screen.pixelDepth属性