• 防刷新倒计时JS代码


     <SCRIPT type="text/javascript">
    var exam_time=${testPaper.examTime*60};//获取后台传的时间
    if(window.name==''){
    maxtime = exam_time;      //此处几句判断是防刷新关键
    }else{
    maxtime = window.name;
    }

     
    function CountDown(){
        if(maxtime>=0){
        hours = Math.floor(maxtime/3600);
        minutes = Math.floor((maxtime-hours*3600)/60);
        seconds = Math.floor(maxtime%60);
        msg = "距离考试结束还有"+hours+"时"+minutes+"分"+seconds+"秒";
        document.getElementById("time").innerHTML = msg;
        if(maxtime == 5*60) alert('注意,还有5分钟!');
        --maxtime;
        window.name = maxtime;
        }
        else{
        document.getElementById("frm").submit();
        clearInterval(timer);
        alert("考试时间到,结束!");
        }
        }
        timer = setInterval("CountDown()",1000);
    </SCRIPT>

    <center><font color="red"><div id="time"></div></font></center> //此处显示倒计时时间

  • 相关阅读:
    动手动脑5
    每日日报
    每日日报
    每日日报
    每日日报
    每日日报
    每日日报
    每周总结
    2020/10/13
    2020/10/20
  • 原文地址:https://www.cnblogs.com/shaoyang/p/5198914.html
Copyright © 2020-2023  润新知