今天用了一个js的中文化框架制作了一个简单的拾色器,它是一个html文件,在浏览器中运行,但如果你想在你的浏览器中运行这个程序,你需要在这个文件中成功地引入zhongwen.js这个文件,否则无法运行。
html部分:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>无标题文档</title>
<script src="js/zhongwen.js"></script>
</head>
<body id="Body">
</body>
</html>
js部分:
var 容器=zw("创建元素")("div",{id:"x"},"");
zw("#Body").添加(容器,"+");
var z={
定位:"绝对",
宽:"100px",
高:"100px",
上:"100px",
左:"200px",
边框:"2px 实线 #000"
}
控制样式("id=x",z);
var k="";
for(var i=0;i<20;i++){
var h="x_"+i;
var 元素="<div id=x_"+i+"></div>";
k+=元素;
}
k+="<input id='input'style='float:left;width:93px;'/>"
zw("#x").添加(k,"+");
var arr=["000","333","666","999","ccc","00c","009","006","003","00f","f00","f33","f66","f99","fcc","fff","0cf","0c6","0c9","0cf"];
var mm="";
for(var i=0;i<20;i++){
样式.宽("id=x_"+i,"20px")
样式.高("id=x_"+i,"20px")
样式.背景颜色("id=x_"+i,"#"+arr[i])
样式.浮动("id=x_"+i,"左边")
mm+="$事件('id=x_"+i+"',"+"'鼠标单击',"+"function(){zw('#input').写入文本框内容('#"+arr[i]+"');样式.背景颜色('id=Body','#"+arr[i]+"')});";
}
eval(mm)