| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 534 人关注过本帖
标题:JavaScript 问题求高手帮解答
取消只看楼主 加入收藏
rock897153
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-8-27
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:0 
JavaScript 问题求高手帮解答
有谁能解释下,下面JavaScript程式,特别是function backcolor()跟function getColor(),感谢
程序代码:
<!DOCTYPE HTML>
<html>
        <head>
                <meta charset="utf-8" />
                <title>any</title>
        </head>
                
<body>
<table cellspacing=0 cellpadding=3 border=1 width="100%" align="center">
<TH>利用 Javascript 改變網頁背景顏色</TH></TABLE><BR>

<A href="#">移動滑鼠接近本行文字即可改變背景顏色!!!</A><p>
<hr>
<form>
請按下按鈕即可改變背景色顏色<p>
<input type="button" value="改變顏色">
</form>
<hr>
<form name="backcolorform">
手動選擇顏色.<p>
<table>
<tr>
<td><input type="radio" name="color" value="green">Green</td>
<td><input type="radio" name="color" value="aqua">Aqua</td>
<td><input type="radio" name="color" value="red">Red</td>
<td><input type="radio" name="color" value="olive">Olive</td>
</tr>
<tr>
<td><input type="radio" name="color" value="teal">Teal</td>
<td><input type="radio" name="color" value="blue">Blue</td>
<td><input type="radio" name="color" value="maroon">Maroon</td>
<td><input type="radio" name="color" value="navy">Navy</td>
</tr>
<tr>
<td><input type="radio" name="color" value="gray">Gray</td>
<td><input type="radio" name="color" value="lime">Lime</td>
<td><input type="radio" name="color" value="fuschia">Fuschia</td>
<td><input type="radio" name="color" value="white">White</td>
</tr>
<tr>
<td><input type="radio" name="color" value="purple">Purple</td>
<td><input type="radio" name="color" value="silver">Silver</td>
<td><input type="radio" name="color" value="yellow">Yellow</td>
<td><input type="radio" name="color" value="black">Black</td>
</tr>
</table>
</form>

</body>
<script src="client/js/work2.js"></script>
</html>




function backcolor(form){
  temp = "";
  for (var i = 0; i < 16; i++) {
        temp = form.color[i].value;
        if (form.color[i].checked){ document.bgColor = temp; }
  }
}

function randombg() { document.bgColor = getColor(); }

function getColor(){
  currentdate = new Date();
  color = currentdate.getSeconds();
  if (color > 44) color = color - 45;
  else if (color > 29) color = color - 30;
  else if (color > 15) color = color - 16;

  if (color == 0 ) return "olive";
  else if (color == 1 ) return "teal";
  else if (color == 2 ) return "red";
  else if (color == 3 ) return "blue";
  else if (color == 4 ) return "maroon";
  else if (color == 5 ) return "navy";
  else if (color == 6 ) return "lime";
  else if (color == 7 ) return "fuschia";
  else if (color == 8 ) return "green";
  else if (color == 9 ) return "purple";
  else if (color == 10 ) return "gray";
  else if (color == 11 ) return "yellow";
  else if (color == 12 ) return "aqua";
  else if (color == 13 ) return "black";
  else if (color == 14 ) return "white";
  else if (color == 15 ) return "silver";
}

麻烦各位了
搜索更多相关主题的帖子: function border center 背景色 title 
2014-08-27 21:09
快速回复:JavaScript 问题求高手帮解答
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017990 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved