JS中5秒中跳转到其他页面

 1 <head>
 2 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
 3 <title>无标题文档</title>
 4 <script type="text/javascript">     
 5 function countDown(secs,surl){     
 6  //alert(surl);     
 7  var jumpTo = document.getElementById('jumpTo');
 8  jumpTo.innerHTML=secs;  
 9  if(--secs>0){     
10      setTimeout("countDown("+secs+",'"+surl+"')",1000);     
11      }     
12  else{       
13      location.href=surl;     
14      }     
15  }     
16 </script> 
17 </head>
19 <body><span id="jumpTo">5</span>秒后自动跳转到http://www.baidu.com/
20 <script type="text/javascript">countDown(5,'http://www.baidu.com/');</script>  
21 </body>
22 </html>
posted @ 2014-12-30 10:11  Python魔法师  阅读(3485)  评论(0编辑  收藏  举报