|
September 24, 1999 Detecting the Number of Colors Tips: September 1999
Yehuda Shiran, Ph.D.
|
|
The screen object combines several useful properties. You can take advantage of its colorDepth property to find out how may colors are supported. For example, if the user has 256 colors, the value of screen.colorDepth would be 8 (28 = 256).This property is supported by Navigator 4.0x, Internet Explorer 4.0x, and above. It normally holds one of the following values: 4, 8, 16, 24. The following cross-browser, backward-compatible piece of code shows how you can display an image based on the number of available colors:
The script may seem a bit complicated, because it accounts for Navigator 2.0x's lack of support for the useful
People who read this tip also read these tips: Look for similar tips by subject: |