js js获取颜色,js颜色条,颜色条筛选,点击颜色条获取颜色值
从网上看到,自动选择标题的颜色值,点击颜色条某处,显示该处颜色值
颜色条地址:颜色条地址
点击中间颜色,该颜色值将出现在下框里。
<!doctype html public -//w3c//dtd xhtml 1.0 transitional//en http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=content-type content=text/html; charset=gb2312 />
<title>点击颜色条获取颜色值,</title>
</head>
<script src=js/color.js type=text/javascript></script>
<body>
<table id=colorpanel cellspacing=0 cellpadding=0 border=0>
<tbody><tr>
<td id=111 valign=center align=middle>网站制作学习网</td>
</tr>
<tr>
<td id=111 valign=center align=middle>颜 色:</td>
<script language=javascript>rgb(pas,width1,height1)</script>
</tr>
</tbody>
</table>
<table id=1 >
<tr>
<td><input type=text name=abc id=abc /></td>
</tr>
</table>
</body>
</html>
//js代码如下,。
var height1 = 18; // define the height of the color bar
var pas = 36; // define the number of color in the color bar
var width1=1; //forasp.cn
var base_hexa = 0123456789abcdef;
function dec2hexa(number)
{ return base_hexa.charat(math.floor(number / 16)) + base_hexa.charat(number % 16);}
function rgb2hexa(tr,tg,tb){return # + dec2hexa(tr) + dec2hexa(tg) + dec2hexa(tb);}
function lightcase(myobject,objname){mm_findobj(objname).bgcolor = myobject.bgcolor;}
col = new array;
col[0] = new array(255,0,255,-1,255,-1);
col[1] = new array(255,0,0,1,0,0);
col[2] = new array(255,-1,255,0,0,0);
col[3] = new array(0,0,255,0,0,1);
col[4] = new array(0,0,255,-1,255,0);
col[5] = new array(0,1,0,0,255,0);
col[6] = new array(255,-1,0,0,255,-1);
function rgb(pas,w,h){
for (j=0;j<6+1;j++){
for (i=0;i<pas+1;i++){
r = math.floor(col[j][0]+col[j][1]*i*(255)/pas);
g = math.floor(col[j][2]+col[j][3]*i*(255)/pas);
b = math.floor(col[j][4]+col[j][5]*i*(255)/pas);
codehex = r + '' + g + '' + b;//www.forasp.cn
document.write('<td bgcolor=\' + rgb2hexa(r,g,b) + '\ onclick=\javascript:change_bg(this.bgcolor);\ width=\'+w+'\ height=\'+h+'\><img height='+h+' width='+w+' border=0 ></td>\n');//网站制作学习网
}
}
}
function change_bg(bg)
{
document.getelementbyid(abc).value = bg;
}