...在jsp页面上显示时钟倒计时?要求是总时间是30分钟,然后倒计时_百度...
发布网友
发布时间:2024-04-08 17:18
我来回答
共3个回答
热心网友
时间:2024-04-11 18:27
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
var maxtime = 30*30 //半个小时,按秒计算,自己调整!
function CountDown(){
if(maxtime>=0){
minutes = Math.floor(maxtime/30);
seconds = Math.floor(maxtime%30);
msg = "距离结束还有"+minutes+"分"+seconds+"秒";
document.all["timer"].innerHTML=msg;
if(maxtime == 5*30) alert('注意,还有5分钟!');
--maxtime;
}
else{
clearInterval(timer);
alert("时间到,结束!");
}
}
timer = setInterval("CountDown()",1000);
</SCRIPT>
</head>
<body>
<div id="timer" style="color:red"></div>
</body>
</html>
热心网友
时间:2024-04-11 18:28
用js啊
<scripttyle="text/javascript">
var urodz= new Date("3/19/2014");
var now = new Date();
var num
var ile = urodz.getTime() - now.getTime();
var dni = Math.floor(ile / (1000 * 60 * 60 * 24));
if (dni >1)
num=dni+1
else if (dni == 1) num=2
else if (dni == 0) num=1
else num=0
document.write(num)
</script>
参考一下吧
热心网友
时间:2024-04-11 18:26
<script type="text/javascript">
var maxtime = 30*60 //半个小时,按秒计算,自己调整!
function CountDown(){
if(maxtime>=0){
minutes = Math.floor(maxtime/60);
seconds = Math.floor(maxtime%60);
msg = "距离结束还有"+minutes+"分"+seconds+"秒";
document.all["timer"].innerHTML=msg;
if(maxtime == 5*60) alert('注意,还有5分钟!');
--maxtime;
}else{
clearInterval(timer);
alert("时间到,结束!");
}
}
timer = setInterval("CountDown()",1000);
</script>
</head>
<body>
<br>
<div align="center" id="timer" style="color:red"></div>
</body>
1分钟=60秒,哈,改正下就OK的!!!