Various page timing jump of countdown jump code summary

  • 2020-03-26 21:38:12
  • OfStack

The following is a summary of the page timing jump (also known as countdown jump), a variety of timing jump code records as follows:

(1) setTimeout function is used to realize timing jump (the following code should be written in the body area)
 
<script type="text/javascript"> 
//After 3 seconds it jumps to the specified page
setTimeout(window.location.href='http://www.baidu.com',3); 
</script> 

(2) HTML code implementation, add the following code in the head area block of the page
 
<!--5 Jumps to the specified page after seconds --> 
<meta http-equiv="refresh" content="5;url=http://www.baidu.com" /> 

(3) a little more complex, more in the timing of the jump after landing
 
<!doctype html> 
<head> 
<meta charset=utf-8" /> 
<title>js The method of regular jump page </title> 
</head> 
<body> 
<script> 
var t=10;//Set the jump time
setInterval("refer()",1000); //Activate 1 second timer
function refer(){ 
if(t==0){ 
location="http://www.baidu.com"; //Set the link address for the jump
} 
document.getElementById('show').innerHTML=""+t+" Seconds after the jump to baidu "; //Display countdown
t--; //Counter decrement
//From:
} 
</script> 
<span id="show"></span> 
</body> 
</html> 

Related articles: