求助((第一回发帖)
我想把一个时钟代码<body bgcolor="#fef4d9" ONLOAD=show5()>
......
和一个倒计时代码
<BODY Onload="startclock()">
......
同时写进一个网页里,可不管怎么弄,倒计时就是不会运行,而且一预览两个的话,就会自动改成ONLOAD=show5()...
问题很弱,希望大家别见笑...
<html> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var Temp2; var timerID = null; var timerRunning = false; function arry() { this.length = 12; this[0] = 31; this[1] = 28; this[2] = 31; this[3] = 30; this[4] = 31; this[5] = 30; this[6] = 31; this[7] = 31; this[8] = 30; this[9] = 31; this[10] = 30; this[11] = 31; } var date = new arry(); function stopclock() { if(timerRunning) clearTimeout(timerID); timerRunning = false; } function startclock() { stopclock(); showtime(); } function showtime() { now = new Date(); var CurMonth = now.getMonth(); var CurDate = now.getDate(); var CurYear = now.getFullYear(); now = null; if (28 < CurDate) { CurDate -= date[CurMonth]; CurMonth++; } if (5 < CurMonth) { CurMonth -= 12; CurYear++; } var Yearleft = 2008 - CurYear; var Monthleft = 5 - CurMonth; var Dateleft = 28 - CurDate; document.dateform.a.value = Yearleft; document.dateform.b.value = Monthleft; document.dateform.c.value = Dateleft; timerID = setTimeout("showtime()",1000); timerRunning = true; } //倒计时 function show5(){ if(!document.layers&&!document.all) return var Digital=new Date() var hours=Digital.getHours() var minutes=Digital.getMinutes() var seconds=Digital.getSeconds() var dn="AM" if(hours>12){dn="PM" hours=hours-12 }if(hours==0) hours=12 if(minutes<=9) minutes="0"+minutes if(seconds<=9) seconds="0"+seconds //change font size here to your desire myclock="<font size='5' face='Arial'><b><font size='2'> 时钟 :</font></br>"+hours+":"+minutes+":" +seconds+" "+dn+"</b></font>" if(document.layers){document.layers.liveclock.document.write(myclock) document.layers.liveclock.document.close() }else if(document.all) liveclock.innerHTML=myclock setTimeout("show5()",1000) } // End --> </script> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>倒计时</title> </head> <BODY Onload="startclock();show5();"> <form name=dateform>距离6/28/2008还有 <input type=text name=a size=2 value="">年 <input type=text name=b size=2 value="">月 <input type=text name=c size=2 value="">天 </form> <span id=liveclock style=position:absolute;left:250px;top:122px;; width: 109px; height: 15px> </span> </body> </html>