Javascript Browser Screen pixelDepth Property

Introduction

Get the color resolution of your screen:

var x = "Color Resolution: " + screen.pixelDepth;

Click the button to display the color resolution of your screen.

View in separate window

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

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

<script>
function myFunction() {/*ww  w  .j  a v a 2  s. c  o  m*/
  var x = "Color resolution: " + screen.pixelDepth + " bits per pixel";
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The pixelDepth property returns the color resolution in bits per pixel of the visitor's screen.

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