Home > Web Front-end > JS Tutorial > body text

JavaScript method to automatically jump to the page after 5 seconds_javascript skills

WBOY
Release: 2016-05-16 16:03:32
Original
3500 people have browsed it

This JavaScript code that controls the page to automatically jump after 5 seconds is often used in many developments. Interested friends can save it!

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>JavaScript控制页面5秒后自动跳转的代码</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.jb51.net/
<script type="text/javascript">
countDown(5,'http://www.jb51.net/');
</script> 
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template