Window screen.colorDepth 屬性
- Ilang Nakaraang Pahina availWidth
- Ilang Susunod na Pahina height
- Bumalik sa Angat Window Screen
定義和用法
colorDepth
屬性返回屏幕的顏色深度。
colorDepth
屬性返回每像素位的深度。
colorDepth
屬性是只讀的。
實例
例子 1
獲取調色板的位深度:
let depth = screen.colorDepth;
例子 2
為 8 位屏幕顯示替代背景顏色(為避免不支持現代顏色的 8 位屏幕使用難看的替代顏色):
if (screen.colorDepth <= 8) //8 位屏幕的簡單藍色背景顏色 document.body.style.background = "#0000FF" else //現代屏幕的絕美藍色背景顏色 document.body.style.background = "#87CEFA"
例子 3
所有屏幕屬性:
let text = "Total width/height: " + screen.width + "*" + screen.height + "<br>" "Available width/height: " + screen.availWidth + "*" + screen.availHeight + "<br>" "Color depth: " + screen.colorDepth + "<br>" "Color resolution: " + screen.pixelDepth;
語法
screen.colorDepth
返回值
類型 | 描述 |
---|---|
數字 |
屏幕調色板的深度(以每像素位為單位): 1, 4, 8, 15, 16, 24, 32, 或 48。 |
瀏覽器支持
所有瀏覽器都支持 screen.colorDepth
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 | 支持 |
- Ilang Nakaraang Pahina availWidth
- Ilang Susunod na Pahina height
- Bumalik sa Angat Window Screen