如何在JavaScript中获取屏幕的像素深度和颜色深度?
Javascript窗口对象提供了许多方法来获取有关浏览器的各种信息。它提供了screen.colorDepth和screen.pixelDepth分别获取浏览器屏幕的颜色深度和像素深度。让我们单独讨论它们。
颜色深度
window对象提供了screen.colorDepth方法来返回颜色深度。颜色深度不过是用于显示一种颜色的位数。所有现代计算机都使用24位或32位硬件进行颜色分辨率。
示例
<html>
<body>
<p id="depth"></p>
<script>
document.getElementById("depth").innerHTML =
"Screen color depth is " + screen.colorDepth;
</script>
</body>
</html>输出结果
Screen color depth is 24
像素深度
Javascript窗口对象提供了screen.pixelDepth 以返回浏览器屏幕的像素深度。
示例
<html>
<body>
<p id="depth"></p>
<script>
document.getElementById("depth").innerHTML =
"Screen pixel depth is " + screen.pixelDepth;
</script>
</body>
</html>输出结果
Screen pixel depth is 24
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短