>You are right, I created the element in the DOM and it worked fine.
>However I found this:
>http://www.javascriptkit.com/dhtmltutors/externalcss.shtml
>And it seems it's exactly what I was looking for in the first place,
>but I don't if I should use it as some browsers (though they are less
>used) do not support the styleSheets object and creating the element
>in the DOM and then remove it, probably works on most of them, I just
>don't like the solution cause it feels like a "work around" and what I
>really want, I can do it with document.styleSheets.

I was going to suggest that, but then you get in to some specifity issues
with CSS (since an element can have multiple classes assigned even specific
styles applied to it.)

If all you're wanting to do is to get the color for a specific class
declaration, then I'd read the stylesheets to do that.

If you're want to know what the *actual* color of a specific element might
be if a certain class is applied, then you have to follow the rules of CSS
to ensure you gather the right question.

Also, while I agree adding the element to the DOM is hackish, you can add
with an absolute position and visibility that's hidden. That way there's no
visual clue that it's been added to the DOM tree. Still hackish, but you're
at least guaranteed that your getting the color *exactly* how its being
shown in the current browser.

-Dan

Reply via email to