The pixelDepth
property returns the color in bits per pixel of the visitor's screen.
pixelDepth |
Yes | 10.0 | Yes | Yes | Yes |
screen.pixelDepth
Type | Description |
---|---|
Number | The color resolution, in bits per pixel. Possible values:
|
The following code shows how to get the color resolution of your screen.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<!-- ww w .j a v a 2s .co m-->
<p id="demo"></p>
<script>
function myFunction() {
var x = "Color resolution: " + screen.pixelDepth + " bits per pixel";
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
All screen properties in one example
<!DOCTYPE html>
<html>
<body>
<div id="demo"></div>
<script>
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>";
<!--from w w w . j av a 2s .co m-->
document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>
The code above is rendered as follows: