『javascript 特效』颜色表 【转】

<html>
<head></head>
<script>
function findObj(n, d){
var p,i,x;
if(!d)d=document;
if((p=n.indexOf("?"))>0 && parent.frames.length){
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if(!(x=d[n]) && d.all)x=d.all[n];
for(i=0; !x && i<d.forms.length; i++)x=d.forms[i][n];
for(i=0; !x && d.layers && i<d.layers.length; i++)x=findObj(n,d.layers[i].document);
if(!x && d.getElementById)x=d.getElementById(n);
return x;
}
function colorsa(c){
findObj('colordiv').style.display='none';
findObj('colortd').style.backgroundColor='#'+c;
alert('#'+c); //修改此处可达到其他不同的效果
}
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 ToHex1(n){
var l1;
n=Math.round(n);
l1=n % 16;
return (hexch[l1]+hexch[l1]);
}
function wc(r, g, b, n){
r=((r*16+r)*3*(15 - n)+0x80*n) / 15;
g=((g*16+g)*3*(15 - n)+0x80*n) / 15;
b=((b*16+b)*3*(15 - n)+0x80*n) / 15;
document.write('<td width="8" bgcolor="#'+ToHex(r)+ToHex(g)+ToHex(b)+'" onclick="colorsa(\''+ToHex(r)+ToHex(g)+ToHex(b)+'\');" onmouseover="this.style.backgroundImage=\'url(color_bg.gif)\';" onmouseout="this.style.backgroundImage=\'\';"></td>');
}
var cnum=new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0);
function colortabl(){
for(i=0; i < 15; i ++){
document.write('<table border="0" cellpadding="0" cellspacing="0"><tr>');
document.write('<td bgcolor="#'+ToHex1(i)+ToHex1(i)+ToHex1(i)+'" height="8" width="8" onclick="colorsa(\''+ToHex1(i)+ToHex1(i)+ToHex1(i)+'\');" onmouseover="this.style.backgroundImage=\'url(color_bg.gif)\';" onmouseout="this.style.backgroundImage=\'\';"></td>')
for(j=0; j < 30; j ++){
n1=j % 5;
n2=Math.floor(j / 5)*3;
n3=n2+3;
wc((cnum[n3]*n1+cnum[n2]*(5 - n1)),(cnum[n3+1]*n1+cnum[n2+1]*(5 - n1)),(cnum[n3+2]*n1+cnum[n2+2]*(5 - n1)), i);
}
document.writeln('</tr></table>');
}
}
</script>
<div id="colordiv" style="display:none;position:absolute;z-index:5;" onmouseout="this.style.display='none';" onmouseover="this.style.display='';">
<script type="text/JavaScript">colortabl();</script>
</div>
<table border="0" cellpadding="0" cellspacing="0" style="background-color:#000000;" id="colortd" onclick="findObj('colordiv').style.display='';">
<tr>
<td><img src="color_ch.gif"></td>
</tr>
</table>
</body>
</html>


图片文件
[img]http://www.piscdong.com/bakimages/color_bg.gif[/img]
[img]http://www.piscdong.com/bakimages/color_ch.gif[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值