随笔 - 14, 文章 - 39, 评论 - 17, 引用 - 0
数据加载中……

网页调色板代码『收集』

1.

<html>
<head>
 
<script>
var tempColor = "0099cc";
function returnColor(){
    var Hcolor = dlgHelper.ChooseColorDlg(tempColor).toString(16);
    with(event.srcElement){
        value = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor;   
        style.backgroundColor = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor;   
    }   
    tempColor = Hcolor
}
</script>
</head>
<body>
<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>

<input type="text" value="#0099CC" size="12" onclick="returnColor()" style="background-color: #0099CC">
</body>
</html>




2.

test1.html
=====================================
<SCRIPT>
var dWin=null;
function doDialog()
{
dWin=showModelessDialog('color.html',window,'status:no;dialogWidth:260px;dialogHeight:200px');
}
</SCRIPT>

<form name=form1>
<input name="color1">
<button onclick="doDialog();" >open</button>
</form>

 


color.html
====================================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2311">
<title>调色板</title>
<script>
var ColorHex=new Array('00','33','66','99','CC','FF')
var SpColorHex=new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF')
var current=null

function intocolor()
{
var colorTable=''
for (i=0;i<2;i++)
{
for (j=0;j<6;j++)
{
colorTable=colorTable+'<tr height=12>'
colorTable=colorTable+'<td width=11 style="background-color:#000000">'

if (i==0){
colorTable=colorTable+'<td width=11 style="background-color:#'+ColorHex[j]+ColorHex[j]+ColorHex[j]+'">'}
else{
colorTable=colorTable+'<td width=11 style="background-color:#'+SpColorHex[j]+'">'}


colorTable=colorTable+'<td width=11 style="background-color:#000000">'
for (k=0;k<3;k++)
{
for (l=0;l<6;l++)
{
colorTable=colorTable+'<td width=11 style="background-color:#'+ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]+'">'
}
}
}
}
colorTable='<table width=253 border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 solid;border-bottom:none;border-collapse: collapse" bordercolor="000000">'
+'<tr height=30><td colspan=21 bgcolor=#cccccc>'
+'<table cellpadding="0" cellspacing="1" border="0" style="border-collapse: collapse">'
+'<tr><td width="3"><td><input type="text" name="DisColor" size="6" disabled style="border:solid 1px #000000;background-color:#ffff00"></td>'
+'<td width="3"><td><input type="text" name="HexColor" size="7" style="border:inset 1px;font-family:Arial;" value="#000000"></td></tr></table></td></table>'
+'<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000" onmouseover="doOver()" onmouseout="doOut()" onclick="doclick()" style="cursor:hand;">'
+colorTable+'</table>';
colorpanel.innerHTML=colorTable
}

function doOver() {
if ((event.srcElement.tagName=="TD") && (current!=event.srcElement)) {
if (current!=null){current.style.backgroundColor = current._background}
event.srcElement._background = event.srcElement.style.backgroundColor
DisColor.style.backgroundColor = event.srcElement.style.backgroundColor
HexColor.value = event.srcElement.style.backgroundColor
event.srcElement.style.backgroundColor = "white"
current = event.srcElement
}
}

function doOut() {
if (current!=null) current.style.backgroundColor = current._background
}

function doclick(){
if (event.srcElement.tagName=="TD"){
dialogArguments.form1.color1.value=event.srcElement._background
window.close();
}
}
</script>

<SCRIPT>
function window.onunload()
{
dialogArguments.dWin=null;
}
</SCRIPT>
</head>

<body onload="intocolor()" topmargin=0 leftmargin=0 scroll=no>
<div id="colorpanel" style="position: absolute;">
</div>
</body>
</html>



posted on 2006-12-05 23:29 mlw2000 阅读(736) 评论(1)  编辑  收藏 所属分类: JavaScript

评论

# re: 网页调色板代码『收集』  回复  更多评论   

谢了!
2008-08-07 11:12 | face

只有注册用户登录后才能发表评论。


网站导航: