JavaScript 倒计时跳转

时间:2021-07-26 00:14:56

 JavaScript 代码如下:

 <span id="time" style="background:red">10</span>秒钟后跳回主页!如果不跳转请点击
 <script language="JavaScript1.2" type="text/javascript">
  function delayURL(url, time) {
   var delay= document.getElementById("time").innerHTML;
   if(delay>0){
    delay--;
    document.getElementById("time").innerHTML=delay;
   }else{
    window.top.location.href=url;
   }
     setTimeout("delayURL('" + url + "')", 1000);
 }
</script>
 <a href="index.jsp">这里</a>
 <script type="text/javascript">
         delayURL("index.jsp",10000);
 </script>