Color reading

Discussion in 'Javascript' started by mark_dp73@yahoo.com, Sep 1, 2005.

  1. Guest

    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).
     
    , Sep 1, 2005
    #1
    1. Advertising

  2. Lee Guest

    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.
     
    Lee, Sep 1, 2005
    #2
    1. Advertising

  3. ASM Guest

    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
     
    ASM, Sep 2, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    3
    Views:
    38,785
    moondaddy
    Apr 28, 2004
  2. PJ6
    Replies:
    4
    Views:
    4,916
  3. Andrew Arace

    BGR Color to Java Color

    Andrew Arace, Sep 13, 2003, in forum: Java
    Replies:
    7
    Views:
    7,911
    Stephen Gilbert
    Sep 16, 2003
  4. Niels Dybdahl

    Color.white vs. Color.WHITE

    Niels Dybdahl, Oct 6, 2004, in forum: Java
    Replies:
    3
    Views:
    464
    Chris Smith
    Oct 6, 2004
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    467
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page