Introduction to the implementation method of automatic jumping of html pages

黄舟
Release: 2017-10-25 10:17:33
Original
1453 people have browsed it


##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>
Copy after login

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>
Copy after login

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=&#39;123.html&#39;;
},1000);
</script>
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!