阅读背景:

js--5秒后自动跳转网页_liuyi0604的博客_js5秒后自动跳转页面

来源:互联网 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="demo"></div>
</body>
</html>
<script>
    var demo = document.getElementById("demo");
    var count = 5;
    var speed = 1000;
    setTimeout(goIndexPage,speed);    //1秒钟之后执行goIndexPage函数
    function goIndexPage(){
        count--;
        demo.innerHTML="<a href='/go.html?url=https://www.baidu.com'>"+count+"秒后自动跳转首页</a>";
        if(count <=0){
            window.location.href = "https://www.baidu.com";  //js页面跳转
        }else{
            setTimeout(goIndexPage,speed);   //递归调用,自己调用自己
        }
    }
</script><!DOCTYPE html>
<html lang="en">
<head>
    <me



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: