Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Color reading

Reply
Thread Tools

Color reading

 
 
mark_dp73@yahoo.com
Guest
Posts: n/a
 
      09-01-2005
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).

 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      09-01-2005
http://www.velocityreviews.com/forums/(E-Mail 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.

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      09-02-2005
(E-Mail Removed) wrote:
> 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



--
Stephane Moriaux et son [moins] vieux Mac
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing font color from current font color to black color Kamaljeet Saini Ruby 0 02-13-2009 04:58 PM
standard way of getting color # string from drawing.color? PJ6 ASP .Net 4 09-15-2005 06:10 PM
Color.white vs. Color.WHITE Niels Dybdahl Java 3 10-06-2004 03:21 PM
how to convert color in style "#e6e6e6" to color object in vb.net moondaddy ASP .Net 3 04-28-2004 04:59 AM
BGR Color to Java Color Andrew Arace Java 7 09-16-2003 05:30 PM



Advertisments