javascript倒计时定时刷新页面代码,可做定时任务代码如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>数据入库任务,请求频次:1min/次</title> {include file="public/css" /} </head> <body> <div class="container my-5"> <div class="row"> <div class="offset-md-2 col-md-8 text-center"> <h4 class="font-weight-bold text-primary"> 定时任务【数据入库】 </h4> <h5>请求频次:1min/次</h5> <hr> <div class="w-100 mb-3"> 刚刚新增了<span class="h5 d-inline font-weight-bold text-danger mx-2">{$insert_num}</span>条数据,更新了<span class="h5 d-inline font-weight-bold text-danger mx-2">{$update_num}</span>条数据 </div> <div class="alert alert-danger"> <span class="text-danger h3 d-inline text-danger" id="timer">60</span> <span class="h5 d-inline"> 秒后<br> 程序将再次自动运行(自动刷新此页面),即:<br><br> <span class="font-weight-bold text-success">自动更新直播数据库</span> </span> </div> </div> </div> </div> {include file="public/js" /} <script type="text/javascript"> timer = setInterval("CountDown()", 1000); var maxtime = 59; //一分钟,按秒计算,自己调整! function CountDown() { if (maxtime >= 0) { seconds = Math.floor(maxtime % 60); $('#timer').html(seconds); --maxtime; } else{ clearInterval(timer); // 时间到,刷新(跳转)页面 self.location.reload(); } } </script> </body> </html>
上一篇: 《建站管家》二次开发文档
下一篇: 漂亮的滚动条样式CSS代码