I have a string from a texarea, now I want to find out if the string is one of the HTML color names here). I know I could simply compare my string to every single one, but that uses up quite some space and isn’t very good. Is there a function like maybe iscolorname(color)?
Or won’t I get around checking every single one?
I have a string from a texarea, now I want to find out if
Share
This question offers some partial anwsers : Javascript function to convert color names to hex codes
A complete one : You could simply create an in memory canvas and do this :
It works because of this :
(from http://www.w3.org/TR/2dcontext/#dom-context-2d-fillstyle)