分享

颜色查询 颜色代码大全 网页版颜色代码选择器

 shanlieng 2012-01-09
 
查看文章
 
颜色查询 颜色代码大全 网页版颜色代码选择器
2011-03-12 1:19

     这是一款网页版颜色代码选择器程序代码。您将代码复制、粘贴到记事本上,文件保存名称为“颜色代码选择器.html”即可。这款选择器小巧玲珑,可以查到各种颜色代码,因为是一张网页,所以不用安装,放在桌面或任务栏上即开即用,得心应手。您可以免去烦恼,不再需要去网站查询颜色代码了。查看效果图

<!--代码开始-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0022)http://blog.csdn.net/electroniXtar/ -->
<html xmlns="http://www./1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网页版颜色代码选择器</title>
</head>
<STYLE type=text/css>
TD {
 FONT-SIZE: 10.8pt
}
BODY {
 FONT-SIZE: 10.8pt;
 background-color: #E6E6FF;
}
BUTTON {
 WIDTH: 5em
}
.STYLE2 {
 font-family: "宋体";
 font-size: 14pt;
 font-weight: bold;
 color: #FF0000;
}
</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');

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()
{ var i;

  if(DrRGB != SelRGB)
  {
    DrRGB = SelRGB;
    for(i = 0; i <= 30; i ++)
      GrayTable.rows(i).bgColor = DoColor(SelRGB, 240 - i * 8);
  }

  SelColor.value = DoColor(RGB.innerText, GRAY.innerText);
  ShowColor.bgColor = SelColor.value;
}
</SCRIPT>

<SCRIPT language=JavaScript event=onclick for=ColorTable>
  SelRGB = event.srcElement.bgColor;
  EndColor();
</SCRIPT>

<SCRIPT language=JavaScript event=onmouseover for=ColorTable>
  RGB.innerText = event.srcElement.bgColor;
  EndColor();
</SCRIPT>

<SCRIPT language=JavaScript event=onmouseout for=ColorTable>
  RGB.innerText = SelRGB;
  EndColor();
</SCRIPT>

<SCRIPT language=JavaScript event=onclick for=GrayTable>
  SelGRAY = event.srcElement.title;
  EndColor();
</SCRIPT>

<SCRIPT language=JavaScript event=onmouseover for=GrayTable>
  GRAY.innerText = event.srcElement.title;
  EndColor();
</SCRIPT>

<SCRIPT language=JavaScript event=onmouseout for=GrayTable>
  GRAY.innerText = SelGRAY;
  EndColor();
</SCRIPT>

<SCRIPT language=JavaScript event=onclick for=Ok>
  window.returnValue = SelColor.value;
  window.close();
</SCRIPT>
</HEAD>
<body>
<BODY width="400" border="10" text=#000000 link=#000000 leftMargin=0 topMargin=0 bgProperties=fixed>
<br>
<table width="350" border="0" align="center" cellpadding="10">
  <tr>
    <td><div align="center" class="STYLE2" >网页版颜色代码选择器</div></td>
  </tr>
</table>
<TABLE width=350
border=2 align=center cellPadding=3 cellSpacing=1 bordercolor="#5E5E5E" bgColor=#dddddd>
  <TBODY>
  <TR bgColor=#ffffff>
    <TD align=middle width="10%"><SELECT onchange=selectchg(this.value)
      name=select1> <OPTION value=1 selected>红</OPTION> <OPTION
        value=2>绿</OPTION> <OPTION value=3>蓝</OPTION> <OPTION
      value=4>灰</OPTION></SELECT> </TD>
    <TD align=middle width="90%">
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
              <TD width="81%" align=right>颜色值
                <INPUT class=memo size=10 name=text1>
                <INPUT class=button onclick=choosecolor() type=button value="确认颜色" name=Button2>
          </TD>

         <TD align=right width="1%"> </TD>
          <TD width="18%">
            <TABLE class=cursorcross height=20 cellSpacing=1 cellPadding=0
            width=40 border=0>
              <TBODY>
              <TR>
                <TD id=customcolor onmouseover=showcolor(this)
                bgColor=#ffffff> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
  <TR bgColor=#ffffff>
    <TD align=middle width="10%">
      <TABLE class=cursorhand id=tableleft cellSpacing=1 cellPadding=0
        border=0><SCRIPT language=VBScript>
function hexit(which)
hexit=hex(which)
end function
</SCRIPT>

        <SCRIPT language=JavaScript>
for(i=0;i<=15;++i)
{document.write('<tr><td align="center">'+ hexit(0+i*17) +'</td><td id="tdleft' + i +'" bgcolor="rgb('+ (0+i*17) + ',0,0)" width="15" height="15" onclick="changeright(this.num)" onmouseover="showcolor(this)"></td></tr>')
 document.all['tdleft' + i].num=i
}
</SCRIPT>

        <TBODY></TBODY></TABLE></TD>
    <TD align=middle width="90%">
      <TABLE class=cursorcross id=tableleft cellSpacing=1 cellPadding=0
border=0>
        <SCRIPT language=JavaScript>
document.write('<tr><td></td>')
for(i=0;i<=15;++i)
{document.write('<td align="center">'+ hexit(0+i*17) +'</td>')}
document.write('</tr>')

for(i=0;i<=15;++i)
{document.write('<tr>')
 document.write('<td align="center">'+ hexit(0+i*17) +'</td>')
 for(j=0;j<=15;++j)
  {document.write('<td id="tdrightr' + i + 'c' + j +'" bgcolor="rgb(0,'+ (0+i*17) + ',' + (0+j*17) + ')" width="15" height="15" onmouseover="showcolor(this)" onclick="clickright(this)"></td>')}
 document.write('</tr>')
}

</SCRIPT>

        <TBODY></TBODY></TABLE></TD></TR>
  <TR bgColor=#ffffff>
    <TD colSpan=2
      height=20>⑴可选16×16×16种颜色。⑵点击左边的颜色会得到更多颜色。⑶点击右边的颜色会固定选取的颜色。⑷输入框可以自定义颜色。(苏扬耕夫修改制作)</TD>
</TR></TBODY></TABLE>
<p><SCRIPT language=JavaScript>
function selectchg(which)
{switch(which)
  {case '1' :leftR();break;
   case '2' :leftG();break;
   case '3' :leftB();break;
   case '4' :leftA();break;
  }
}
function leftR()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb('+ (0+i*17) + ',0,0)'}
 rightR(0)
}
function leftG()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb(0,'+ (0+i*17) + ',0)'}
 rightG(0)
}
function leftB()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb(0,0,'+ (0+i*17) + ')'}
 rightB(0)
}
function leftA()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb('+ (0+i*17) + ','+ (0+i*17) + ','+ (0+i*17) + ')'}
 rightA()
}
function rightR(which)
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+which*17) + ',' + (0+i*17) + ','+ (0+j*17) + ')'}
    }
}
function rightG(which)
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*17) + ',' + (0+which*17) +  ',' + (0+j*17) + ')'}
    }
}
function rightB(which)
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*17) + ','+ (0+j*17)+ ',' + (0+which*17) + ')'}
    }
}
function rightA()
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*16+j) + ','+ (0+i*16+j)+ ',' + (0+i*16+j) + ')'}
    }
}
var rightclicked=false
function clickright(which)
{if(rightclicked){rightclicked=false;showcolor(which)}else{rightclicked=true}
}
function changeright(which)
{switch(select1.value)
  {case '1' :rightR(which);break;
   case '2' :rightG(which);break;
   case '3' :rightB(which);break;
 }
}
function showcolor(which)
{if(rightclicked)return;
 text1.value=which.bgColor
 choosecolor()
}
function choosecolor()
{customcolor.bgColor=text1.value
}
</SCRIPT>
</p>
</BODY></HTML>
<!--代码结束-->

怎样保存和使用html 代码,请参考这里的1至9 >>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约