Screen colorDepth 属性

定义和用法
colorDepth 属性返回目标设备或缓冲器上的调色板的比特深度。
语法
screen.colorDepth
浏览器支持
所有主要浏览器都支持 colorDepth 属性
实例s
返回调色板的位深度:
<script>
document.write("颜色深度: " + screen.colorDepth);
</script>
在8比特屏显示交替的背景颜色:
<script>
if (screen.colorDepth <= 8)
//为8位屏幕的简单的蓝色背景色
document.body.style.background = "#0000FF"
else
//为现代屏幕的华丽的蓝色背景色
document.body.style.background = "#87CEFA"
</script>
更多实例
本例包含了所有screen属性
<h3>你的屏幕:</h3>
<script>
document.write("总宽度/高度: ");
document.write(screen.width + "*" + screen.height);
document.write("<br>");
document.write("可以宽度/高度: ");
document.write(screen.availWidth + "*" + screen.availHeight);
document.write("<br>");
document.write("颜色深度: ");
document.write(screen.colorDepth);
document.write("<br>");
document.write("颜色分辨率: ");
document.write(screen.pixelDepth);
</script>
