回复 2# 的帖子
这是倒计时的.
<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;
}
// End -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>倒计时</title>
</head>
<BODY Onload="startclock()">
<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>
</body>
</html>
这是时钟的
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>时钟</title>
</head>
<body bgcolor="#fef4d9" ONLOAD=show5()>
<span id=liveclock style=position:absolute;left:250px;top:122px;; width: 109px; height: 15px>
</span>
<SCRIPT language=javascript>
<!--
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)
}
//>
</SCRIPT></body>
</html>