HTML js 页面倒计时后跳转至新页面

HTML:

 1 <body>
 2     <p>操作错误!还有<span id="sp">5</span>秒跳转到交换机备份页面...</p>
 3   <a href="#" onclick="stop()">停止</a>
 4 
 5     <script type="text/javascript">
 6         var i=5;
 7         function changeTime(){
 8             document.getElementById("sp").innerHTML=i;
 9             i--;
10         }
11         changeTime();
12         var inId=window.setInterval("changeTime()",1000);
13         function stop(){
14             window.clearInterval(inId);
15         }
16         function autoRedirect(){
17             window.location="{% url 'sw_mgmt:sw_br' %}";    //跳转页面设置
18         }
19         window.setInterval("autoRedirect()",5000);
20     </script>
21 
22 </body>

 

posted @ 2020-06-22 18:11  语~默  阅读(803)  评论(0编辑  收藏  举报