This is a very useful script for both web developers and graphic designers.
Simply pick your desired color from the drop-down selector and watch the background change.
Click the "convert button" and the rgb and hex codes will be displayed for your selected color.
Then all you need to do is copy these codes to your page(s).
BLACK TEXT
WHITE TEXT
BLUE TEXT
RED TEXT
GOLD TEXT
BROWN TEXT
ORANGE TEXT
GREY TEXT
CAYAN TEXT
GREEN TEXT
YELLOW TEXT
Код скрипта
<html>
<head>
</head>
<body BGCOLOR="#FFFFFF" TEXT="#000000" link="darkblue" onLoad="initializer()">
<script>
<!--
function initializer()
{
hexidec=new makeArray(1);
}
function makeArray(n)
{
this.length = n;
for (var i=1; i<=n;i++)
this[i]=0;
return this;
}
function getColor(form){
form.hexadecimal.value=document.bgColor;
rgb=form.hexadecimal.value;
c="0123456789abcdef";
red=c.indexOf(rgb.substring(1,2))*16+c.indexOf(rgb.substring(2,3));
green=c.indexOf(rgb.substring(3,4))*16+c.indexOf(rgb.substring(4,5));
blue=c.indexOf(rgb.substring(5,6))*16+c.indexOf(rgb.substring(6,7));
form.red.value=red;
form.green.value=green;
form.blue.value=blue;
form.hexadecimal.focus();
form.hexadecimal.select();
}
function getHex(form)
{
var c="0123456789abcdef";
if ((form.red.value >255) || (form.green.value > 255) || (form.blue.value > 255))
{window.alert("What colors are you trying to convert? Value: 0 to 255!")}else
{
red=form.red.value;
green=form.green.value;
blue=form.blue.value;
with (Math) {
numOne=c.substring(floor(red/16),floor(red/16)+1);
numTwo=c.substring(red%16,(red%16)+1);
numThree=c.substring(floor(green/16),floor(green/16)+1);
numFour=c.substring(green%16,(green%16)+1);
numFive=c.substring(floor(blue/16),floor(blue/16)+1);
numSix=c.substring(blue%16,(blue%16)+1);
}
form.hexadecimal.value="#"+numOne+""+numTwo+""+numThree+""+numFour+""+numFive+""+numSix;
form.red.focus();
form.red.select();
document.bgColor=form.hexadecimal.value;
form.hexadecimal.focus();
form.hexadecimal.select();
}}
function getRGB(form)
{
hex=form.hexadecimal.value;
pound=0;
for (i=0;i<7;i++){
hexidec[i]=hex.charAt(i);
temp=hexidec[i];
if (temp=='#')
pound++;
if ((temp=='a')||(temp=='A'))
hexidec[i]=10;
if ((temp=='b')||(temp=='B'))
hexidec[i]=11;
if ((temp=='c')||(temp=='C'))
hexidec[i]=12;
if ((temp=='d')||(temp=='D'))
hexidec[i]=13;
if ((temp=='e')||(temp=='E'))
hexidec[i]=14;
if ((temp=='f')||(temp=='F'))
hexidec[i]=15;
}
form.red.value=((hexidec[0+pound]*16)- -hexidec[1+pound]);
form.green.value=((hexidec[2+pound]*16)- -hexidec[3+pound]);
form.blue.value=((hexidec[4+pound]*16)- -hexidec[5+pound]);
document.bgColor=form.hexadecimal.value;
}
//-->
</script>
This is a very useful script for both web developers and graphic designers.<br>
Simply pick your desired color from the drop-down selector and watch the background change.<br>
Click the "convert button" and the rgb and hex codes will be displayed for your selected color.<br>
Then all you need to do is copy these codes to your page(s).</p>
<form>
<div align="center"><center><table>
<tr>
<td align="center"><div align="left"><p><b>Color:</b> <select name="colors"
onChange="document.bgColor = form.colors.options[colors.selectedIndex].value" size="1">
<option value="white" defaultSelected="true"> White </option>
<option value="aliceblue"> Alice Blue </option>
<option value="antiquewhite"> Antique White </option>
<option value="aqua"> Aqua </option>
<option value="aquamarine"> Aquamarine </option>
<option value="azure"> Azure </option>
<option value="beige"> Beige </option>
<option value="bisque"> Bisque </option>
<option value="black"> Black </option>
<option value="blanchedalmond"> Blanchedalmond </option>
<option value="blue"> Blue </option>
<option value="blueviolet"> Blue-Violet </option>
<option value="brown"> Brown </option>
<option value="burlywood"> Burlywood </option>
<option value="cadetblue"> Cadet Blue </option>
<option value="chartreuse"> Chartreuse </option>
<option value="chocolate"> Chocolate </option>
<option value="coral"> Coral </option>
<option value="cornflowerblue"> Cornflower Blue </option>
<option value="cornsilk"> Cornsilk </option>
<option value="crimson"> Crimson </option>
<option value="cyan"> Cyan </option>
<option value="darkblue"> Dark Blue </option>
<option value="darkcyan"> Dark Cyan </option>
<option value="darkgoldenrod"> Dark Goldenrod </option>
<option value="darkgray"> Dark Gray </option>
<option value="darkgreen"> Dark Green </option>
<option value="darkkhaki"> Dark Khaki </option>
<option value="darkmagenta"> Dark Magenta </option>
<option value="darkolivegreen"> Dark Olive-Green </option>
<option value="darkorange"> Dark Orange </option>
<option value="darkorchid"> Dark Orchid </option>
<option value="darkred"> Dark Red </option>
<option value="darksalmon"> Dark Salmon </option>
<option value="darkseagreen"> Dark Sea Green </option>
<option value="darkslateblue"> Dark Slate Blue </option>
<option value="darkslategray"> Dark Slate Gray </option>
<option value="darkturquoise"> Dark Turquoise </option>
<option value="darkviolet"> Dark Violet </option>
<option value="deeppink"> Deep Pink </option>
<option value="deepskyblue"> Deep Sky Blue </option>
<option value="dimgray"> Dim Gray </option>
<option value="dodgerblue"> Dodger Blue </option>
<option value="firebrick"> Firebrick </option>
<option value="floralwhite"> Floral White </option>
<option value="forestgreen"> Forest Green </option>
<option value="fuchsia"> Fuchsia </option>
<option value="gainsboro"> Gainsboro </option>
<option value="ghostwhite"> Ghost White </option>
<option value="gold"> Gold </option>
<option value="goldenrod"> Goldenrod </option>
<option value="gray"> Gray </option>
<option value="green"> Green </option>
<option value="greenyellow"> Green-Yellow </option>
<option value="honeydew"> Honeydew </option>
<option value="hotpink"> Hot Pink </option>
<option value="indianred"> Indian Red </option>
<option value="indigo"> Indigo </option>
<option value="ivory"> Ivory </option>
<option value="khaki"> Khaki </option>
<option value="lavender"> Lavender </option>
<option value="lavenderblush"> Lavender-Blush </option>
<option value="lawngreen"> Lawn Green </option>
<option value="lemonchiffon"> Lemon Chiffon </option>
<option value="lightblue"> Light Blue </option>
<option value="lightcoral"> Light Coral </option>
<option value="lightcyan"> Light Cyan </option>
<option value="lightgoldenrodyellow"> Light Goldenrod Yellow </option>
<option value="lightgreen"> Light Green </option>
<option value="lightgrey"> Light Grey </option>
<option value="lightpink"> Light Pink </option>
<option value="lightsalmon"> Light Salmon </option>
<option value="lightseagreen"> Light Sea Green </option>
<option value="lightskyblue"> Light Sky Blue </option>
<option value="lightslategray"> Light Slate Gray </option>
<option value="lightsteelblue"> Light Steel Blue </option>
<option value="lightyellow"> Light Yellow </option>
<option value="lime"> Lime </option>
<option value="limegreen"> Lime-Green </option>
<option value="linen"> Linen </option>
<option value="magenta"> Magenta </option>
<option value="maroon"> Maroon </option>
<option value="mediumaquamarine"> Medium Aquamarine </option>
<option value="mediumblue"> Medium Blue </option>
<option value="mediumorchid"> Medium Orchid </option>
<option value="mediumpurple"> Medium Purple </option>
<option value="mediumseagreen"> Medium Sea Green </option>
<option value="mediumslateblue"> Medium Slate Blue </option>
<option value="mediumspringgreen"> Medium Spring Green </option>
<option value="mediumturquoise"> Medium Turquoise </option>
<option value="mediumvioletred"> Medium Violet-Red </option>
<option value="midnightblue"> Midnight Blue </option>
<option value="mintcream"> Mint Cream </option>
<option value="mistyrose"> Misty Rose </option>
<option value="moccasin"> Moccasin </option>
<option value="navajowhite"> Navajo White </option>
<option value="navy"> Navy </option>
<option value="oldlace"> Old Lace </option>
<option value="olive"> Olive </option>
<option value="olivedrab"> Olive Drab </option>
<option value="orange"> Orange </option>
<option value="orangered"> Orange-Red </option>
<option value="orchid"> Orchid </option>
<option value="palegoldenrod"> Pale Goldenrod </option>
<option value="palegreen"> Pale Green </option>
<option value="paleturquoise"> Pale Turquoise </option>
<option value="palevioletred"> Pale Violet-Red </option>
<option value="papayawhip"> Papaya Whip </option>
<option value="peachpuff"> Peach Puff </option>
<option value="peru"> Peru </option>
<option value="pink"> Pink </option>
<option value="plum"> Plum </option>
<option value="powderblue"> Powder Blue </option>
<option value="purple"> Purple </option>
<option value="red"> Red </option>
<option value="rosybrown"> Rosy Brown </option>
<option value="royalblue"> Royal Blue </option>
<option value="saddlebrown"> Saddle Brown </option>
<option value="salmon"> Salmon </option>
<option value="sandybrown"> Sandy Brown </option>
<option value="seagreen"> Sea Green </option>
<option value="seashell"> Seashell </option>
<option value="sienna"> Sienna </option>
<option value="silver"> Silver </option>
<option value="skyblue"> Sky Blue </option>
<option value="slateblue"> Slate Blue </option>
<option value="slategray"> Slate Gray </option>
<option value="snow"> Snow </option>
<option value="springgreen"> Spring Green </option>
<option value="steelblue"> Steel Blue </option>
<option value="tan"> Tan </option>
<option value="teal"> Teal </option>
<option value="thistle"> Thistle </option>
<option value="tomato"> Tomato </option>
<option value="turquoise"> Turquoise </option>
<option value="violet"> Violet </option>
<option value="wheat"> Wheat </option>
<option value="white"> White </option>
<option value="whitesmoke"> White Smoke </option>
<option value="yellow"> Yellow </option>
<option value="yellowgreen"> Yellow-Green </option>
</select> <input type="button" size="3" name="color" value="Convert to RGB/Hex"
onClick="getColor(this.form)"> </td>
</tr>
</table>
</center></div>
<div align="center"><center><p><br>
<b>RGB:</b> <font color="red">
<b>Red</b> <input type="text" size="4" name="red" value="255">
<font color="green"><b>Green</b> <input type="text" size="3" name="green" value="255">
<font color="blue"><b>Blue</b></font> <input type="text" size="4" name="blue" value="255">
</p></center></div>
<p><br></p>
<div align="center"><center><table>
<tr>
<td align="center"><b>HEX:</b> </td>
<td align="center"><input type="text" size="8" name="hexadecimal" value="#ffffff"></td>
</tr>
</table>
</center></div>
</form>
</font></font>
<p align="center"><B>BLACK TEXT
<font color="#FFFFFF">WHITE TEXT
</font><font color="#0000FF">BLUE TEXT
</font><font color="#FF0000">RED TEXT<br><br>
</font><font color="#FFD700">GOLD TEXT
</font><font color="#A52A2A">BROWN TEXT
</font><font color="#FFA500">ORANGE TEXT
</font><font color="#BEBEBE">GREY TEXT<br><br>
</font><font color="#00FFFF">CAYAN TEXT
</font><font color="#00FF00">GREEN TEXT
</font><font color="#FFFF80">YELLOW TEXT</font></B></p>
</body>
</html>