Example of implementing timing page jump function in JavaScript

  • 2021-07-21 06:53:24
  • OfStack

In this paper, an example is given to describe the realization of timing page jump function by JavaScript. Share it for your reference, as follows:


<!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=utf-8" />
<title>Test</title>
<script type="text/javascript" language="javascript" >
<!--
var time = 8; // Time , Seconds 
function Redirect(){
window.location = "https://www.ofstack.com/";
}
var i = 0;
function dis(){
document.all.s.innerHTML = " Remaining " + (time - i) + " Seconds ";
i++;
}
timer=setInterval('dis()', 1000);// Display time 
timer=setTimeout('Redirect()',time * 1000); // Jump 
//-->
</script>
</head>
<body>
<span id="s"></span>
</body>
</html>

More readers interested in JavaScript can check the topics of this site: "Summary of JavaScript Time and Date Operation Skills", "Summary of JavaScript Switching Special Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Error and Debugging Skills", "Summary of JavaScript Data Structure and Algorithm Skills", "Summary of JavaScript Traversal Algorithm and Skills" and "Summary of JavaScript Mathematical Operation Usage"

I hope this article is helpful to everyone's JavaScript programming.


Related articles: