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"; }
麻烦各位了