您的位置:首页 > 其它

考试系统的倒计时

2011-11-02 14:45 127 查看
<script type="text/javascript">

var times = ${exame.limiteTime * 60};//将分钟换算成秒

function setTimers() {

hours = Math.floor(times / 3600);

minutes = Math.floor(times / 60 % 60);

seconds = Math.floor(times % 60);

if (times > 0) {

msg = "离考试结束还有" + hours + "时" + minutes + "分" + seconds + "秒";

document.getElementById("timerColorIds").innerHTML = msg;

if (times < 1 * 60) {

document.getElementById("timerColorIds").className = "timercolor";//重新为该区域的显示信息赋新的css样式

if (times == 0) {

alert("考试结束");

document.myform.submit();

}

}

--times;

}

}

//倒计时的定时器

var timer2 = setInterval("setTimers()", 1000);

</script>

<html>

<div id="timerColorIds"

style="right: 0px, bottom : 1px; margin-top: 200px">

</div>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: