473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Determining background color of a cell...

ehm
OK, I know that this sounds like a "newbie" question, but I have
searched the web with no luck.

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.
Jul 20 '05 #1
1 3017
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.'
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dhunter | last post by:
I'm kind of new to CSS and hope someone knows how to fix a problem I've been fighting with for days. I'm trying to create a mouseover navbar with CSS which inserts a colored background JPG that...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
5
by: proximus | last post by:
Hi, I am trying to change the background of table TD's. The problem is that I have no access to the HTML code. SO I am trying to alter this using Javascript/DOM in an external .js file. I...
2
by: patrick.waldo | last post by:
Hi all, I am trying to figure out a way to read colors with xlrd, but I did not understand the formatting.py module. Basically, I want to sort rows that are red or green. My initial attempt...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.