Javascript Browser Screen colorDepth Property

Introduction

Get the bit depth of the color palette:

var x = "Color Depth: " + screen.colorDepth;

Click the button to display the bit depth of the color palette.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from w w  w.  jav a 2 s.  c  o  m
  var x = "Color Depth: " + screen.colorDepth + " bits per pixel";
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The colorDepth property returns the bit depth of the color palette in bits per pixel.

Possible values:

  • 1 bit per pixel
  • 4 bits per pixel
  • 8 bits per pixel
  • 15 bits per pixel
  • 16 bits per pixel
  • 24 bits per pixel
  • 32 bits per pixel
  • 48 bits per pixel



PreviousNext

Related