width只讀屬性返回屏幕的總寬度(以像素為單位)。
使用height屬性獲取屏幕的總高度(以像素為單位)。
screen.width
var x = "Total Width: " + screen.width;測試看看?/?
所有瀏覽器完全支持width屬性:
屬性 | ![]() | ![]() | ![]() | ![]() | ![]() |
width | 是 | 是 | 是 | 是 | 是 |
返回值: | 一個數(shù)字,表示用戶屏幕的總寬度,以像素為單位 |
---|
此示例顯示所有屏幕屬性:
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屬性