Home >Web Front-end >HTML Tutorial >Introduction to the implementation method of automatic jumping of html pages

Introduction to the implementation method of automatic jumping of html pages

黄舟
黄舟Original
2017-10-25 10:17:331478browse


##1.1 Method 1 Add the e8e496c15ba93d81f6ea4fe5f55a2244 tag directly within the 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1 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=&#39;123.html&#39;;
},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!

Statement:
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