Subj.
I've written something, but it's hackish.
Is there a proper way to do this?Code:function rgb(r, g, b) { return (r<<16) + (g<<8) + b; } function colorToInt(s) { if(s.charAt(0)=='#' && s.length==7) // Opera return parseInt("0x"+s.substring(1)); if(s.charAt(0)=='#' && s.length==4) // IE return parseInt("0x"+s.charAt(1)+s.charAt(1)+s.charAt(2)+s.charAt(2)+s.charAt(3)+s.charAt(3)); if(s.substring(0, 3)=="rgb") // Netscape / Mozilla return eval(s); alert(s); // WTF } [...] var myColor = colorToInt(document.getElementById("myelement").style.color); [...]



Reply With Quote



Bookmarks