调色板

项目中需要从页面选择颜色定制背景色,google了一个样例,但其html代码太大所以自己写了一段js替之。

觉得还是比较有用的一段小代码,希望可以帮到一些朋友。

[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>the color</title>

<script>
var Color = {
outprint: function() {
var s='',i=0,cc = this.getCC();
for(var b=1;b<=56;b+=11){
for(var a=1;a<=281;a+=8){s+=this.getArea(a,b,a+6,b+9,cc[i++]);}
}
document.write(s);
},
getCC: function() {
var c=['00','33','66','99','cc','ff'],cc=[];
for(var j=c.length;j>0;j--){
var ccm=c[j-1];
for(var i=0;i<c.length;i++){
var ccl=c[i];
for(var l=0;l<c.length;l++){cc[cc.length]=ccl+ccm+c[l];}
}
}
return cc;
},
getArea: function(a,b,c,d,cc) {
return '<area shape="rect" coords='+a+','+b+','+c+','+d+
' href="javascript:Color.theColor(\'#'+cc+'\')"/>';
},
theColor: function(cvalue) {
//to do
//alert(cvalue);
document.getElementById('theColor').style.color=cvalue;
}
}
</script>
</head>
<body>
<span id="color_selection" style="display:;">
<img height="67" src="palette.gif" width="289" useMap="#spmap" border="0"/>
</span>

<map name="spmap"><script>Color.outprint();</script></map>
<span id="theColor" name="theColor" style="color:#000000;">THE COLOR</span>
</body>
</html>[/code]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值