Color reading

M

mark_dp73

I need to extract the background color of a div in a format that can be
manipulated mathematically. When I retrieve style.backgroundColor, I
get rgb(255,255,255), even though it was put in as #FFFFFF. Is there a
way to get the hex value out of backgroundColor or pull the individual
color values out of the rgb()? I would prefer not parsing out the rgb()
string (mainly because I think that's just a sloppy way of doing it).
 
L

Lee

(e-mail address removed) said:
I need to extract the background color of a div in a format that can be
manipulated mathematically. When I retrieve style.backgroundColor, I
get rgb(255,255,255), even though it was put in as #FFFFFF. Is there a
way to get the hex value out of backgroundColor or pull the individual
color values out of the rgb()? I would prefer not parsing out the rgb()
string (mainly because I think that's just a sloppy way of doing it).

var myRGB=style.background.color.match(/\d+/g)

seems cleaner than converting Hex characters to decimal.
 
A

ASM

I need to extract the background color of a div in a format that can be
manipulated mathematically. When I retrieve style.backgroundColor, I
get rgb(255,255,255), even though it was put in as #FFFFFF.

each browser makes its own cook ...

most use rgb(xxx,xxx,xxx)
other : #FFFFFF
and other : #ffffff
some returns strange values

I think, except if it is for you with only one browser,
you can't expect to get every time same combination
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top