JavaScript用函数改变页面背景颜色
发布网友
发布时间:2022-04-26 19:11
我来回答
共1个回答
热心网友
时间:2022-04-22 23:00
给你写了个JS代码,拿去试试吧!<style type="text/css">
<!--
body { font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 0px; margin-right: 0px}
A { COLOR: black; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none }
A:hover { COLOR: red; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: underline }
a:active { font: 9pt "宋体"; cursor: hand; color: #FF0033 }
-->
</style>
</head>
<body>
<hr>
<center><font color=red face="隶书" size=6>颜色选择器</font></center>
<center>
<table border=1 bordercolor=#000000 borderlight=green style="border-collapse: collapse" cellpadding="0" cellspacing="0">
<tr><td align=center><font size=5 color=red face="Arial, Helvetica, sans-serif"><strong>下面为效果显示区</strong></font></td></tr>
<tr><td align=center><FORM>
<SELECT Size=22 name=clr onChange="document.bgColor=this.options[this.selectedIndex].value">
<OPTION VALUE="blue">blue</OPTION>
<OPTION VALUE="aquamarine">aquamarine</OPTION>
<OPTION VALUE="chocolate">chocolate</OPTION>
<OPTION VALUE="darkred">dark red</OPTION>
<OPTION VALUE="gold">gold</OPTION>
<OPTION VALUE="red">red</OPTION>
<OPTION VALUE="yellow">yellow</OPTION>
<OPTION VALUE="hotpink">hotpink</OPTION>
<OPTION VALUE="lime">lime</OPTION>
<OPTION VALUE="darkkhaki">dark khaki</OPTION>
<OPTION VALUE="cadetblue ">cadet blue</OPTION>
<OPTION VALUE="darkgoldenrod">dark goldenrod</OPTION>
<OPTION VALUE="darkslateblue">dark slate blue</OPTION>
<OPTION VALUE="deeppink">deep pink</OPTION>
<OPTION VALUE="darksalmon">dark salmon</OPTION>
<OPTION VALUE="salmon">salmon</OPTION>
<OPTION VALUE="tan">tan</OPTION>
<OPTION VALUE="wheat">wheat</OPTION>
<OPTION VALUE="tomato">tomato</OPTION>
<OPTION VALUE="springgreen">springgreen</OPTION>
<OPTION VALUE="turquoise">turquoise</OPTION>
<OPTION VALUE="FFFFFF" SELECTED> White</OPTION>
</select></form>
</td></tr></table></center>
<center>
<SCRIPT LANGUAGE="JavaScript">
</script></center>