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

字號:


    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 align=middle>網(wǎng)站制作學(xué)習(xí)網(wǎng)</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');//網(wǎng)站制作學(xué)習(xí)網(wǎng)
    }
    }
    }
    function change_bg(bg)
    {
    document.getelementbyid(abc).value = bg;
    }