js js获取颜色,js颜色条,颜色条筛选,点击颜色条获取颜色值
从网上看到,自动选择标题的颜色值,点击颜色条某处,显示该处颜色值
颜色条地址:颜色条地址
点击中间颜色,该颜色值将出现在下框里。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<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代码如下,www.forasp.cn网站制作学习网原创,转载请注明。
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;
}
中国足彩网信息请查看IT技术专栏