<body>
<SCRIPT LANGUAGE="JavaScript">
var maxtime;
if(window.name==''){
maxtime = 10*60; //10分钟倒计时
}else{
maxtime = window.name;
}
function CountDown(){
if(maxtime>=0){
minutes = Math.floor(maxtime/60);
seconds = Math.floor(maxtime%60);
msg = "距离考试结束还有"+minutes+"分"+seconds+"秒";
document.getElementById("timer").innerHTML = msg;
if(maxtime == 5*60) alert('注意,考试时间还有5分钟!');
--maxtime;
window.name = maxtime;
}
else{
clearInterval(timer);
alert("考试时间到,结束!");
}
}
timer = setInterval("CountDown()",1000);
</SCRIPT>
<div id="timer" style="color:red"></div>
</body>
使用JS实现页面倒计时功能,防止页面刷新重置计时
最新推荐文章于 2024-03-14 11:54:11 发布