I want to use non-web-safe colors in several places on my website, including for the background. But I am concerned about visitors with older computers.
Is there any code I can use that will change the color from the non-web-safe color to the nearest web-safe color if the visitor cannot see non-web-safe colors?
As this question cannot, to my knowledge, be answered with simple HTML, I'm posting this JavaScript solution to offer an alternative means:
It's possible to use
screen.colorDepth
to return the color depth, in bits, of the user's screen. With the exception of a faulty/erroneous implementation in Firefox 3.x and 4.1 (beta).Addenda with respect to PPK, Chromium 11/Ubuntu 11.04 also returns
24
rather than32
, so Firefox may have been correct.JS Fiddle demo.
Reference: