日期:2014-05-17 浏览次数:20594 次
<%--倒计时--%> <script type="text/javascript" language="JavaScript"> secs = 59; // Number of secs to delay -CHINA-studio wait = secs * 100; minute = 3; //考试总时间 //循环调用秒的减方法 cycle(); function cycle() { for (i = 0; i <= (wait / 100); i++) { //将i*1000改为i*100查看最后的效果 window.setTimeout("doUpdate(" + i + ")", i * 1000); } } function doUpdate(num) { if (num == (wait / 100)) { cycle(); //三分钟前提醒考生交卷 if (minute == 3) { alert("还有三分钟时间,请抓紧时间答卷!"); } //时间到,提交表单 if (minute <= 0) { // document.exam.action=""; document.all.btnhandin.click(); } minute--; } else { wut = (wait / 100) - num; //使得输出格式为00:00 s = wut < 10 ? "0" + wut : wut; m = minute < 10 ? "0" + minute : minute; //将剩余时间显示在页面上 document.getElementById('lefttime').innerHTML = "剩余时间: + m + "分" + s + "秒"; } } </script>
<td> <asp:Label ID="lefttime" runat="server" Text="Label"></asp:Label></td> </tr>