Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <4454122.7EdHYbU6jS@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Mon, 25 Jun 2012 05:14:15 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 56 NNTP-Posting-Date: 25 Jun 2012 05:14:22 CEST NNTP-Posting-Host: 6e105fa0.newsspool1.arcor-online.net X-Trace: DXC=j[oAj3QP[3ZE47KDAk81NWic==]BZ:af^4Fo<]lROoRQnkgeX?EC@@P:B3KFXJVReRDZm8W4\YJN\b@mF9jNikdU Am 2012-06-24 13:31, justaguy meinte: >> I have an iframe which uses the #BDD3FF background color to make it >> more appealing, however, recently I realize on some low end laptops >> this background color looks deep blue (bad), so, I wonder if there's >> a way to detect the user's graphics card via a web browser (since it's >> a web app) so as to provide appropriate background color. > > No. And it wouldn't help, since the user could still use a custom color > profile or have changed the default settings of his display. There is the host object referred to by the host-defined `screen' property of the Global Object or window host object, which has a `pixelDepth' property in more recent DOM implementations to indicate the number of bits available for the color value of a pixel. It can be used to work around this issue, but it may not be reliable: The best solution – if the CD allows it – is to use what I call True Web- safe Colors (`#000', `#003', …, `#00f`, …, `#030`, …, `#03f`, …, `#fff'). See also: . JSX:color.js [1] defines jsx.dom.css.Color.prototype.getWebSafe() which computes the nearest Web-safe color for a given color. It can be used as follows: /* Include a `script' element for color.js and dependencies */ var myColor = new jsx.dom.css.Color("#BDD3FF"); var mySafeColor = myColor.getWebSafe(); console.log(mySafeColor); jsx.dom.css.Color instances inherit a toString() method (equivalent to the toRGBAString() method) that returns the CSS3 RGBA notation for the color value. Therefore, references can be used verbatim in CSS scripting: element.style.color = mySafeColor; However, they also inherit toHex(), toRGBString(), and toJSON() methods, for less advanced CSS implementations and other purposes. jsx.dom.css.Color.prototype.toHex() returns the short notation if all quads of each color value component are equal to the other quad (as recommended by the CSS Specifications); it requires jsx.string.leadingZero() which we have discussed yesterday. PointedEars ___________ [1] -- Danny Goodman's books are out of date and teach practices that are positively harmful for cross-browser scripting. -- Richard Cornford, cljs, (2004)