I noticed that there is now a large color table in the excanvas source:
http://code.google.com/p/explorercanvas/source/browse/trunk/excanvas.js#sl_svn69_260
You actually don't need this. :)
The function below will convert *any* color value to hex:
function toHex(color) {
var body = createPopup().document.body,
range = body.createTextRange();
body.style.color = color.toLowerCase();
var value = range.queryCommandValue("ForeColor").toString(16);
return "#" + "000000".slice(0, -value.length) + value;
};
-dean
Actually, that should be:
function toHex(color) {
var body = createPopup().document.body,
range = body.createTextRange();
body.style.color = color;
var value = range.queryCommandValue("ForeColor");
value = ((value & 0x0000ff) << 16) | (value & 0x00ff00) | ((value &
0xff0000) >>> 16);
value = value.toString(16);
return "#000000".slice(0, 7 - value.length) + value;
};
I blogged it here in the end:
http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/
-dean