點(diǎn)擊顏色條生成顏色值

字號(hào):


    js js獲取顏色,js顏色條,顏色條篩選,點(diǎn)擊顏色條獲取顏色值
    從網(wǎng)上看到,自動(dòng)選擇標(biāo)題的顏色值,點(diǎn)擊顏色條某處,顯示該處顏色值
    顏色條地址:顏色條地址
    點(diǎn)擊中間顏色,該顏色值將出現(xiàn)在下框里。
    <!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>點(diǎn)擊顏色條獲取顏色值,</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>網(wǎng)站制作學(xué)習(xí)網(wǎng)</TD>
    </TR>
    <TR>
    <TD id="111"  vAlign=center>顏 色:</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');//網(wǎng)站制作學(xué)習(xí)網(wǎng)
    }
    }
    }
    function change_bg(bg)
    {
    document.getElementById("abc").value = bg;
    }