JavaScript implements the method of automatic page jump after 5 seconds

  • 2020-05-30 19:20:26
  • OfStack

This JavaScript control page 5 seconds after the automatic jump code in many development often need to use, interested friends can collect 1!


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>JavaScript Control page 5 Code that jumps automatically after seconds </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> Automatically jump to after seconds https://www.ofstack.com/
<script type="text/javascript">
countDown(5,'https://www.ofstack.com/');
</script> 
</body>
</html>

I hope this article has been helpful to your javascript programming.


Related articles: