错误: 无法设置属性“innerHTML”的值: 对象为 null 或未定义
<script type="text/javascript"; language="JavaScript">
<!--
var maxtime = 1 * 60 //一个小时,按秒计算
function CountDown() {
if (maxtime >= 0) {
minutes = Math.floor(maxtime / 60);
seconds = Math.floor(maxtime % 60);
msg = "距离结束时间还有" + minutes + "分" + seconds + "秒";
document.getElementById("timer").innerHTML = msg;
if (maxtime == 0.5 * 60) alert('注意,还有30秒!');
--maxtime;
}
else {
clearInterval(timer);
alert("时间到!考试结束");
document.all.BtnSubmit.click();
}
}
timer = setInterval("CountDown()", 1000);
</script>
<div id="timer" style="color:red"> </div>
------解决方案--------------------