SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Set as HEX, outputs as RGB

    I just spent a long while trying to work out why my colour picker wasn't working and just realised although I set the background colours as HEX using inline styling they output as RGB when requested with javascript. I have a RGB to HEX converter, but is there a way of getting it to alert what it was actually set it too?
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,116
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Post the code.

    I have a RGB to HEX converter, but is there a way of getting it to alert what it was actually set it too?
    If you've got a function then you just need to alert the result don't you?
    Code javascript:
    alert(rgbToHex(255,255,255)); // #ffffff

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I got it using
    Code:
    set_hex_colours(rgb2hex(this.backgroundColor.replace(/(rgb\(|\ |\))/gi,"")));
    But weird that I set it as one, the one I'm working with, and the browser sets it as another.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  4. #4
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,116
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    You're right, it is one of those weird inconsistencies in the DOM between browsers.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •