ka****@earthlink.net (ehm) writes:
How can I determine the background color of a cell in a table? I
have tried using all of the following:
obj.style.background
obj.style.bgColor
obj.bgColor
obj.style.color
However, all of these either return null or "undefined". Any help
would be greatly appreciated.
The style property corresponds to the style attribute in HTML. If you
haven't set the background color with the style attribute, it won't be
in the style property either.
What you want is the computed value of the background-color CSS property.
There are different ways to do that: The W3C DOM method and IE's method.
In IE, you can write
obj.currentStyle.backgroundColor
In W3C DOM (supported by Mozilla and Opera 7.2 (still in beta)), you
can write
document.defaultView.getComputedStyle(obj,"").back groundColor
There is no rule saying how the result is formatted. In Opera and
Mozilla, a white background is reported as "rgb(255, 255, 255)", while
IE6 says "white".
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'