Convert RGB to ColorName String Javascript

I want to find out if the DOM element has a style, for example color: red. If defined in an inline style like

<input type="text" style="color:Red"> 

I can easily get it using JavaScript

But what about whether this is defined in the role - I mean as the css class and assign the DOM Element class

With javascript, I know that I can get the color using some call to the computedStyle method and give it the name of the property, but it brings me color in RGB number mode in Firefox, and in IE it gets the color name

My question here is how to convert RGB to a simple color name?

+5
source share
4 answers

Here is the library that will do this: Name That Color - http://chir.ag/projects/name-that-color/

+9
source

Here is an example of a function that you could call in this answer:

Javascript function to convert color names to hexadecimal codes

This is a conversion from a name to a hexadecimal value.

+4
source

I think these are the names supported in most browsers, you can store them in a dictionary and search for them: http://www.febooti.com/products/iezoom/online-help/html-color-names-x11-color- chart.html

X11 color names are a superset of those defined in css.

+2
source

The color name for the RGB converter lookup table will help, start here: http://web.njit.edu/~walsh/rgb.html .
On the other hand, someone could have created it earlier, so try Google: https://encrypted.google.com/search?num=100&q=SlateGray1+SlateGray2+inurl%3A.js

+2
source

All Articles