本文實(shí)例講述了JS實(shí)現(xiàn)的在線調(diào)色板。分享給大家供大家參考,具體如下:
運(yùn)行效果截圖如下:

具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>ColorSchemer - Online Color Scheme Generator</title>
<META NAME="keywords" CONTENT="web page design - color - scheme - color scheme - color schemer - colorschemer - rgb - hex - web color - html color - color pick - pick - picker">
<META NAME="description" CONTENT="Generate matching color schemes like never before!">
<link rel="STYLESHEET" type="text/css" href="default.css">
<script language="JavaScript" type="text/javascript" src="funcs.js"></script>
</head>
<body bgcolor="#FCFCF9" text="#000000" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" rightmargin="0" onLoad="ChangeColors(51,102,255);">
<div ID="ColorInput">
<div>Current Color</div>
<div><div ID="currentColor"> </div></div>
<form name="codes" id="codes">
<div>
<div>
<table cellspacing="0" cellpadding="0">
<tr>
<td>R:</td>
<td><input type="text" name="r" value="0" maxlength="3"></td>
</tr>
<tr>
<td>G:</td>
<td><input type="text" name="g" value="0" maxlength="3"></td>
</tr>
<tr>
<td>B:</td>
<td><input type="text" name="b" value="0" maxlength="3"></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="Set RGB" onClick="ChangeColors(document.getElementById('codes').r.value,document.getElementById('codes').g.value,document.getElementById('codes').b.value);"></td>
</tr>
<tr>
<td colspan="2">#<input type="text" name="hex" value="000000" maxlength="6"></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="Set HEX" onClick="SetHex(document.getElementById('codes').hex.value);"></td>
</tr>
</table>
<input type="button" value="Lighten Scheme" onClick="LightenScheme();">
<input type="button" value="Darken Scheme" onClick="DarkenScheme();">
</div></div>
</form>
</div>
<div ID="Wheel">
<div ID="swatch0">
<div><div ID="0" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="0RGB">255.255.255</div>
<div ID="0HEX">#FFFFFF</div>
</div>
<div ID="swatch1">
<div><div ID="1" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="1RGB">255.255.255</div>
<div ID="1HEX">#FFFFFF</div>
</div>
<div ID="swatch2">
<div><div ID="2" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="2RGB">255.255.255</div>
<div ID="2HEX">#FFFFFF</div>
</div>
<div ID="swatch3">
<div><div ID="3" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="3RGB">255.255.255</div>
<div ID="3HEX">#FFFFFF</div>
</div>
<div ID="swatch4">
<div><div ID="4" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="4RGB">255.255.255</div>
<div ID="4HEX">#FFFFFF</div>
</div>
<div ID="swatch5">
<div><div ID="5" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="5RGB">255.255.255</div>
<div ID="5HEX">#FFFFFF</div>
</div>
<div ID="swatch6">
<div><div ID="6" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="6RGB">255.255.255</div>
<div ID="6HEX">#FFFFFF</div>
</div>
<div ID="swatch7">
<div><div ID="7" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="7RGB">255.255.255</div>
<div ID="7HEX">#FFFFFF</div>
</div>
<div ID="swatch8">
<div><div ID="8" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="8RGB">255.255.255</div>
<div ID="8HEX">#FFFFFF</div>
</div>
<div ID="swatch9">
<div><div ID="9" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="9RGB">255.255.255</div>
<div ID="9HEX">#FFFFFF</div>
</div>
<div ID="swatch10">
<div><div ID="10" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="10RGB">255.255.255</div>
<div ID="10HEX">#FFFFFF</div>
</div>
<div ID="swatch11">
<div><div ID="11" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="11RGB">255.255.255</div>
<div ID="11HEX">#FFFFFF</div>
</div>
<div ID="swatchm1">
<div><div ID="m1" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="m1RGB">255.255.255</div>
<div ID="m1HEX">#FFFFFF</div>
</div>
<div ID="swatchm2">
<div><div ID="m2" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="m2RGB">255.255.255</div>
<div ID="m2HEX">#FFFFFF</div>
</div>
<div ID="swatchm3">
<div><div ID="m3" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="m3RGB">255.255.255</div>
<div ID="m3HEX">#FFFFFF</div>
</div>
<div ID="swatchm4">
<div><div ID="m4" onClick="SetHex(this.style.backgroundColor);"> </div></div>
<div ID="m4RGB">255.255.255</div>
<div ID="m4HEX">#FFFFFF</div>
</div>
</div>
<script language="JavaScript">DrawPalette();</script>
</body>
</html>
希望本文所述對大家JavaScript程序設(shè)計(jì)有所幫助。