var maxtime = 45 * 60 //一个小时,按秒计算,自己调整!
function CountDown() {
if (maxtime >= 0) {
minutes = Math.floor(maxtime / 60);
seconds = Math.floor(maxtime % 60);
msg = "剩余时间:<span style='font-size:25px; color:red;font-family: Arial;'><strong>" + minutes + ":" + seconds + "</strong></span>";
document.all["timer"].innerHTML = msg;
if (maxtime == 5 * 60) alert('注意,还有5分钟!');
--maxtime;
}
else {
clearInterval(timer);
alert("考试时间到!");
submit_Exam();
}
}
timer = setInterval("CountDown()", 1000);
<div id="timer" style=" font-size:13px;"></div>