index.jsp
颜色
<input name="color" type="text" id="color" size="3" readonly="yes" style="background-color:#000000" onClick="colorpick(this);">
</SELECT>
<script language="javascript">
function colorpick(field){
var rtn = window.showModalDialog("color.jsp","","dialogWidth:225px;dialogHeight:170px;status:no;help:no;scrolling=no;scrollbars=no");
if(rtn!=null)
field.style.background=rtn;
return;
}
</script>
color.jsp
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页拾色器</title>
</head>
<body>
<script language="JavaScript">
<!--
var h = new Array(6)
h[0] = "FF";
h[1] = "CC";
h[2] = "99";
h[3] = "66";
h[4] = "33";
h[5] = "00";
function action(RGB) {
//alert('您选择的颜色是:#'+RGB);
parent.window.returnValue="#"+RGB;
window.close();
}
function Mcell(R, G, B) {
document.write('<td bgcolor="#' + R + G + B + '">');
document.write('<a href="#" onClick="action(/'' + (R + G + B) + '/')">');
document.write('<img border=0 height=12 width=12 /')" alt=/'#'+R+G+B+'/'>');
document.write('</a>');
document.write('</td>');
}
function Mtr(R, B) {
document.write('<tr>');
for (var i = 0; i < 6; ++i) {
Mcell(R, h[i], B);
}
document.write('</tr>')
}
function Mtable(B) {
document.write('<table cellpadding=0 cellspacing=0 border=0>');
for (var i = 0; i < 6; ++i) {
Mtr(h[i], B);
}
document.write('</table>');
}
function Mcube() {
document.write('<table cellpadding=0 cellspacing=0 border=0><tr>'); //
for (var i = 0; i < 6; ++i) {
if(i%3==0){
document.write('<tr>');
}
document.write('<td bgcolor="#FFFFFF">');
Mtable(h[i])
document.write('</td>');
}
if(i%3==0){
document.write('</tr>');
}
document.write('</tr></table>');
}
Mcube()
-->
</script>
</body>
</html>