js控制5秒后页面自动跳转

<head>javascript控制5秒后页面自动跳转</head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">     
function countDown(secs,surl){     
 //alert(surl);     
 var jumpTo = document.getElementById('jumpTo');
 jumpTo.innerHTML=secs;  
 if(--secs>0){     
     setTimeout("countDown("+secs+",'"+surl+"')",1000);     
     }     
 else{       
     location.href=surl;     
     }     
 }     
</script> 
</head>
<body><span id="jumpTo">5</span>秒后自动跳转到http://www.baidu.com/
<script type="text/javascript">countDown(5,'http://www.baidu.com/');</script>  
</body>
</html>

 

posted @ 2012-08-04 15:43  妍珊  阅读(5926)  评论(0编辑  收藏  举报