[转载]在线考试javaScript倒计时

时间:2023-03-09 23:26:12
[转载]在线考试javaScript倒计时
 <script type="text/javascript">
/*
================== hi.baidu.com/coolinc ===
*/
var h=0; //设置考试时间(小时单位)
var m=0.1; //设置考试时间(分钟单位)
var timeShowId="timeshow"; //设置时间显示层ID
var TimeNum=h*60*60+m*60;
var timeStr;
function ChangeTime(){
TimeNum--;
if(TimeNum > 0){
timeStr=setTimeout("ChangeTime()",1000);
}
else{
document.form1.submit();
}
document.getElementById(timeShowId).innerHTML="在线考试系统提示你的时间还剩"+Math.floor(TimeNum/60)+"分"+TimeNum%60+"秒";
//window.status="在线考试系统提示你的时间还剩"+Math.floor(TimeNum/60)+"分"+TimeNum%60+"秒";
}
</script>
<body onLoad="ChangeTime()">
<div id="timeshow" style="position:absolute;left:1px;top:1px;width:250px;height:20px;line-height:20px;text-align:center;font-size:12px;color:#000;background-color:#CCC;border:1px solid #333;"></div>
<br />
<form action="NS_Exam_result.asp" method="post" name="form1" id="form1">
...做题
<input type="submit" name="Submit" value="交卷">
</form>
</body>

转自百度空间 coolinc