JS 考试倒计时

来源:互联网 发布:最难就业的专业 知乎 编辑:程序博客网 时间:2024/06/05 18:07
if(confirm("开始考试!")!=true)
{
    window.location.href = "";
}


var maxtime = 90*60 //一个小时,按秒计算,自己调整!
function CountDown(){
if(maxtime>=0){
minutes = Math.floor(maxtime/60);
seconds = Math.floor(maxtime%60);
minutes = minutes>=10?minutes:'0'+minutes;
seconds = seconds>=10?seconds:'0'+seconds;
msg = "考试剩余时间:"+minutes+"分"+seconds+"秒";
document.all["navbar"].innerHTML=msg;
if(maxtime == 5*60) alert('注意,还有5分钟考试结束!');
--maxtime;
}
else{
clearInterval(timer);
alert("时间到,考试结束,请交卷!");
return false;
}
}
0 0