Colors names to Hex values

Mone <[email protected]>
Newsgroups gmane.comp.web.dom.wdf
Message-ID <[email protected]>
Hi people,
I've a question, nothing transcendental, but a useful trick.
This code converts a color name (like "navyblue" or "green") to his 
hexadecimal correspondent:

function nameToHex(colorName) {
      document.bgColor = colorName;
      return document.bgColor;
}

did you know an alternative that doesn't use the document object?
Something like this (that doesn't works):

function nameToHex(colorName) {
   var fooDiv = document.createElement("div");    
fooDiv.style.backgrouundColor = colorName;
   return fooDiv.style.backgrouundColor;
}

Thanks a lot,
   Bye!


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page
http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/9rHolB/TM
--------------------------------------------------------------------~-> 

Unsubscribe
[email protected]

List info
http://www.quirksmode.org/dom/list.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wdf-dom/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.