##1.1 Method 1 Add the tag directly within the
tag. The code is as follows:<head> <meta http-equiv="refresh" content="3;URL=res.html"> <!--3秒之后自动跳转到res.html页面--> </head>
1.2 Method 2 Use the JS setTimeout function to define an expression to be executed after the specified millisecond value. The code is as follows:
<script> setTimeout(function (){ location.href=" res.html "; },3000); //3秒之后自动执行函数,直接跳转到res.html页面 </script>
1.3 Method 3 The flaw of the above two examples is that they can jump, but they don’t know when to jump. To implement the countdown 3-2-1, the JS settimeout function cannot do it. You need to use the JS setInterval function to define an expression to be executed every time the specified millisecond value passes. The code is as follows:
<script> var x=3;//利用了全局变量来执行 setInterval(function (){ x--; x>0? document.getElementById("info").innerHTML=x : location.href='123.html'; },1000); </script>
The above is the detailed content of Introduction to the implementation method of automatic jumping of html pages. For more information, please follow other related articles on the PHP Chinese website!