Screen pixelDepth Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Screen

Description

The pixelDepth property returns the color resolution of the visitor's screen.

Return Value

A Number, representing the color resolution, 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

The following code shows how to get the color resolution of your screen:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

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

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

</body>
</html>

Related Tutorials