<HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <TITLE>颜色</TITLE> <STYLE TYPE="text/css"> td {font-size: 10.8pt} body {font-size: 10.8pt} BUTTON {width:5em} </STYLE> <SCRIPT LANGUAGE=JavaScript> var SelRGB = ''; var DrRGB = ''; var SelGRAY = '120'; var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); //return srcElement function eGetSrcElement(e){ var theEvent= window.event || e; var srcElement= theEvent.srcElement; var thisisie=1; if(!srcElement) { srcElement=theEvent.target; thisisie=0; } return srcElement; } //return isie function eGetIsIE(e){ var theEvent= window.event || e; var srcElement= theEvent.srcElement; var thisisie=1; if(!srcElement) { srcElement=theEvent.target; thisisie=0; } return thisisie; } function ToHex(n) { var h, l; n = Math.round(n); l = n % 16; h = Math.floor((n / 16)) % 16; return (hexch[h] + hexch[l]); } function DoColor(c, l) { var r, g, b; r = '0x' + c.substring(1, 3); g = '0x' + c.substring(3, 5); b = '0x' + c.substring(5, 7); if(l > 120) { l = l - 120; r = (r * (120 - l) + 255 * l) / 120; g = (g * (120 - l) + 255 * l) / 120; b = (b * (120 - l) + 255 * l) / 120; }else { r = (r * l) / 120; g = (g * l) / 120; b = (b * l) / 120; } return '#' + ToHex(r) + ToHex(g) + ToHex(b); } function EndColor(e) { var i,rbgtext,graytext; var thisisie=eGetIsIE(e); if(DrRGB != SelRGB) { DrRGB = SelRGB; for(i = 0; i <= 30; i ++) GrayTable.rows(i).bgColor = DoColor(SelRGB, 240 - i * 8); } rbgtext=thisisie==1?RGB.innerText:RGB.textContent; graytext=thisisie==1?GRAY.innerText:GRAY.textContent; SelColor.value = DoColor(rbgtext,graytext); ShowColor.bgColor = SelColor.value; } //fun function ColorTableOnclick(e){ var srcElement=eGetSrcElement(e); SelRGB = srcElement.bgColor; EndColor(e); } function ColorTableOnmouseover(e){ var thisisie=eGetIsIE(e); var srcElement=eGetSrcElement(e); if(thisisie==1) { RGB.innerText = srcElement.bgColor; } else { RGB.textContent = srcElement.bgColor; } EndColor(e); } function ColorTableOnmouseout(e){ var thisisie=eGetIsIE(e); if(thisisie==1) { RGB.innerText=SelRGB; } else { RGB.textContent=SelRGB; } EndColor(e); } //fun2 function GrayTableOnclick(e){ var srcElement=eGetSrcElement(e); SelGRAY = srcElement.title; EndColor(e); } function GrayTableOnmouseover(e){ var thisisie=eGetIsIE(e); var srcElement=eGetSrcElement(e); if(thisisie==1) { GRAY.innerText=srcElement.title; } else { GRAY.textContent=srcElement.title; } EndColor(e); } function GrayTableOnmouseout(e){ var thisisie=eGetIsIE(e); if(thisisie==1) { GRAY.innerText=SelGRAY; } else { GRAY.textContent=SelGRAY; } EndColor(e); } //fun3 function OkOnclick(){ window.returnValue = SelColor.value; window.close(); } </SCRIPT> </HEAD> <BODY bgcolor="#cccccc"> <div align="center"><center><table border="0" cellspacing="10" cellpadding="0"><tr><td> <TABLE ID=ColorTable BORDER=0 CELLSPACING=0 CELLPADDING=0 style='cursor:pointer' onclick="ColorTableOnclick(event);" onmouseover="ColorTableOnmouseover(event);" onmouseout="ColorTableOnmouseout(event);"> <SCRIPT LANGUAGE=JavaScript> function wc(r, g, b, n) { r = ((r * 16 + r) * 3 * (15 - n) + 0x80 * n) / 15; g = ((g * 16 + g) * 3 * (15 - n) + 0x80 * n) / 15; b = ((b * 16 + b) * 3 * (15 - n) + 0x80 * n) / 15; document.write('<TD BGCOLOR=#' + ToHex(r) + ToHex(g) + ToHex(b) + ' height=8 width=8></TD>'); } var cnum = new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0); for(i = 0; i < 16; i ++) { document.write('<TR>'); for(j = 0; j < 30; j ++) { n1 = j % 5; n2 = Math.floor(j / 5) * 3; n3 = n2 + 3; wc((cnum[n3] * n1 + cnum[n2] * (5 - n1)), (cnum[n3 + 1] * n1 + cnum[n2 + 1] * (5 - n1)), (cnum[n3 + 2] * n1 + cnum[n2 + 2] * (5 - n1)), i); } document.writeln('</TR>'); } </SCRIPT> </TABLE></td><td> <TABLE ID=GrayTable BORDER=0 CELLSPACING=0 CELLPADDING=0 style='cursor:pointer' onclick="GrayTableOnclick(event);" onmouseover="GrayTableOnmouseover(event);" onmouseout="GrayTableOnmouseout(event);"> <SCRIPT LANGUAGE=JavaScript> for(i = 255; i >= 0; i -= 8.5) document.write('<TR BGCOLOR=#' + ToHex(i) + ToHex(i) + ToHex(i) + '><TD TITLE=' + Math.floor(i * 16 / 17) + ' height=4 width=20></TD></TR>'); </SCRIPT> </TABLE></td></tr></table></center></div> <div align="center"><center><table border="0" cellspacing="10" cellpadding="0"> <tr><td rowspan="2" align="center"> 选中色彩<table ID=ShowColor border="1" width="40" height="30" cellspacing="0" cellpadding="0"> <tr><td></td></tr></table></td> <td rowspan="2">基色: <SPAN ID=RGB></SPAN><BR> 亮度: <SPAN ID=GRAY>120</SPAN><BR> 代码: <INPUT TYPE=TEXT SIZE=7 ID=SelColor></td> <td><BUTTON ID=Ok TYPE=SUBMIT onclick="OkOnclick();">确定</BUTTON></td></tr> <tr><td><BUTTON ONCLICK="window.close();">取消</BUTTON></td></tr></table></center></div> </BODY> </HTML>