Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Screen colorDepth Property

Screen colorDepth Property

Screen Object Reference Screen object


Definition and Usage

The colorDepth property returns the bit depth of the palette on the target device or buffer.

Syntax

screen.colorDepth


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the colorDepth property


Examples

Example 1

Return the bit depth of the palette:

The output of the above example is:

Try it »

Example 2

Display alternating background colors on an 8-bit screen:

if (screen.colorDepth<=8)

    // A simple blue background color for 8-bit screens

    document.body.style.background="#0000FF"

else

    // A fancy blue background color for modern screens

    document.body.style.background="#87CEFA"

Try it »


More examples

This example contains all screen properties


Screen Object Reference Screen object