怎么跟改页面的背景颜色

iggi 2002-04-20 10:48:25
谢谢
...全文
68 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
weidegong 2002-04-20
  • 打赏
  • 举报
回复
举一反三嘛 什么都要教
iggi 2002-04-20
  • 打赏
  • 举报
回复
如果是在框架网页上怎么用?
WnEunfn 2002-04-20
  • 打赏
  • 举报
回复
//这只是一个范例……
<p onmousemove="textcolor()">将鼠标移上将改变背景色</p>
<p><script language="VBScript">
sub textcolor
document.bgColor=int(256*256*256*rnd)
document.fgColor=int(256*256*256*rnd)
end sub
</script>
8988 2002-04-20
  • 打赏
  • 举报
回复
1、主页面
<body id="bodyID">
<button onclick=setClr(bodyID)>改变颜色</button>
<script>
function setClr(clrObj){
retclr=window.showModalDialog("getColor.htm",clrObj.bgColor,"status=no;help=no");
if (retclr!="" && retclr!=null) {clrObj.bgColor=retclr;}
}
</script>
</body>

2、取色器,保存为getColor.htm
<html>

<head>
<title>调色板</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body topmargin="0" leftmargin="0">

<script>
window.returnValue="";
window.dialogHeight="154px";
window.dialogWidth ="366px";
clr=new Array();
clr[0]="00";
clr[1]="33";
clr[2]="66";
clr[3]="99";
clr[4]="CC";
clr[5]="FF";

document.write ('<table width=360 border="1" cellspacing="0" cellpadding="0"><tr>');
for(r=0;r<6;r++){
document.write('<td><table style=font-size:7pt border="0" cellspacing="0" cellpadding="0">');
for (g=0;g<=6;g++){
document.write('<tr>');
if(g<6)for (b=0;b<6;b++) document.write('<td onclick=ThisClr(this.bgColor) width=10 bgcolor='+clr[r]+clr[g]+clr[b]+'> </td>');
else for(b=0;b<6;b++) document.write('<td onclick=ThisClr(this.bgColor) width=10 bgcolor='+clr[r]+clr[r]+clr[r]+'> </td>');

document.write('</tr>');
}
document.write('</table></td>');
}
document.write('</tr></table>');



</script>
<table border="1" width="360" cellspacing="0" cellpadding="0" style="font-size: 10pt" bordercolor="#D7EBFF">
<tr>
<td width="29" id="oldClr"> </td>
<td width="29" id="newClr"> </td>
<td width="68" style="padding-left: 5">#<input type="text" onchange="ThisClr(this.value)" name="newVar" size="7" style="border-style: solid; border-width: 0"></td>
<td width="280" align="center" style="color: #008000">单击色块选择颜色</td>
</tr>
<tr>
<td colspan="4" align="center" style="padding-top: 3"><img border="0" src="img/Ok1.gif" style="cursor:hand" onclick="doOK()" width="66" height="23"> <img border="0" src="img/Cancel1.gif" style="cursor:hand" onclick="window.close()" width="66" height="23"></td>
</tr>
</table>

</body>
<script>
function ThisClr(bgclr){
bgclr=bgclr.toUpperCase().substr(1);
newClr.bgColor=bgclr;
newVar.value=bgclr;
}

rgb=window.dialogArguments+"";
ThisClr(rgb);
oldClr.bgColor=newClr.bgColor;
function doOK(){
window.returnValue=newClr.bgColor.toUpperCase();
window.close();
}
</script>

</html>

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧