# 如何制作倒计时时钟（页面上）

mascotzhuang 2004-08-03 01:46:24

...全文
259 点赞 收藏 5

5 条回复

andraw2002 2004-08-03

<script language="JavaScript" type="text/javascript">
<!--//
var hour,minute,second,totalSecond,actTime;
var isBegin;

totalSecond = 0;
hour = 0; minute = 0; second = 15; //设置作题时间
totalSecond = (hour * 60 * 60) + (minute * 60) + second;
isBegin = true;

function clock(intSign){
if(intSign==1){ //开始答题时
for(var i=0;i<document.St.length;i++){
var temp = document.St[i].name.substring(0, 3);
if(temp=="zd_"){
document.St[i].disabled = false;
}
}
}
var conHourToSecond,conMinuteToSecond;
conHourToSecond = 60 * 60; conMinuteToSecond = 60; //设置常量
if(totalSecond-- > 1){
var strHour,strMinute,strSecond;
strHour = Math.floor(totalSecond/conHourToSecond);
strMinute = Math.floor((totalSecond - strHour*conHourToSecond)/conMinuteToSecond);
strSecond = totalSecond - strHour*conHourToSecond - strMinute*conMinuteToSecond;
document.all.Clock.value = strHour + ":" + strMinute + ":" + strSecond;
actTime = window.setTimeout("clock(0)", 1000);
}else{
document.all.Clock.value = "0:0:0";
TimeOut();
alert("答题时间到！停止作答！");
window.clearTimeout(actTime);
}
}

function initClock(obj){ //初始时，不能作答，只有点击开始后才能作答
for(var i=0;i<document.St.length;i++){
var temp = document.St[i].name.substring(0, 3);
if(temp=="zd_"){
document.St[i].disabled = true;
}
}
obj.value = hour + ':' + minute + ':' + second;
}

function TimeOut(){ //答题时间到
for(var i=0;i<document.St.length;i++){
var temp = document.St[i].name.substring(0, 3);
if(temp=="zd_"){
document.St[i].disabled = true;
}
}
}
//-->
</script>

787912 2004-08-03
<script language=vbscript>
window.setInterval "showtime",1000
sub showtime
dim d1,d2
d1=cdate("2005-1-1 0:0:0")
d2=now
window.divtime.innerHTML="现在距离2005年1月1日0时0分0秒还有 <font color=red><b>" & clng((cdbl(d1)-cdbl(d2))*24*60*60) & "</b></font>秒"
end sub
</script>

tianjy 2004-08-03
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta name="vs_defaultClientScript" content="VBScript">
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<div id=divtime></div>
<script language=vbscript>
window.setInterval "showtime",1000
sub showtime
dim d1,d2
d1=cdate("2005-1-1 0:0:0")
d2=now
window.divtime.innerHTML="现在距离2005年1月1日0时0分0秒还有 <font color=red><b>" & clng((cdbl(d1)-cdbl(d2))*24*60*60) & "</b></font>秒"
end sub
</script>

</body>
</html>

smallyear 2004-08-03

wsdzmhongm 2004-08-03
<span>

ASP

2.8w+

ASP即Active Server Pages，是Microsoft公司开发的服务器端脚本环境。

2004-08-03 01:46