小斌gzb 发表于 2013-2-7 20:20:32

定时跳转js

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>定时跳转JS</title>
</head>
<script language="javascript" type="text/javascript">

function GoNext(seconds,url){         
   var next = document.getElementById('totalSecond');
   next.innerHTML=seconds;   
   if(--seconds>0){      
         setTimeout("GoNext("+seconds+",'"+url+"')",1000);      
         }      
   else{         
         location.href=url;      
         }      
   }

</script>

<body>

<span id="totalSecond">5</span>


</body>
<script type="text/javascript">GoNext(5,'http://www.baidu.com');</script>
</html>
页: [1]
查看完整版本: 定时跳转js