Screen colorDepth 属性
页面下方有更多实例。
定义和用法
colorDepth 属性返回用于显示图像的调色板的位深度(以每像素位为单位)。
浏览器支持
属性 | |||||
---|---|---|---|---|---|
colorDepth | Yes | Yes | Yes | Yes | Yes |
语法
screen.colorDepth
技术细节
返回值: | 数值,表示用于显示图像的调色板的位深度,单位为每像素位。 可能的值:
|
---|
更多实例
实例
为8比特屏幕显示另一种背景色:
if (screen.colorDepth <= 8)
//simple blue background color for 8 bit screens
document.body.style.background = "#0000FF"
else
//fancy blue background color for modern screens
document.body.style.background = "#87CEFA"
亲自试一试 »
//simple blue background color for 8 bit screens
document.body.style.background = "#0000FF"
else
//fancy blue background color for modern screens
document.body.style.background = "#87CEFA"
实例
所有屏幕属性:
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>";
亲自试一试 »
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>";
❮ Screen 对象