HTML 页面加载计时器 5秒倒计时 后跳转页面

HTML 页面加载计时器 5秒倒计时 后跳转页面

转载链接:https://blog.csdn.net/qq_43021813/article/details/82820965

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>正在跳转...</title>
    <script>
        function countDown() {
            //获取初始时间
            var time = document.getElementById("Time");

            //获取到id为time标签中的数字时间
            if (time.innerHTML == 0) {
                //等于0时清除计时,并跳转该指定页面
                window.location.href="https://www.baidu.com";
            } else {
                time.innerHTML = time.innerHTML - 1;
            }
        }

        //1000毫秒调用一次
        window.setInterval("countDown()", 1000);
    </script>
    <style>
        #main {
            position: absolute;
            width: 420px;
            height: 200px;
            left: 50%;
            top: 50%;
            margin-left: -210px;
            margin-top: -100px;
        }

        #Time {
            font-size: 25px;
            text-align: center;
            color: red;
        }

        .boxs {
            font-size: 25px;
            text-align: center;
            margin: 0 auto;
        }

        #Font {
            font-size: 20px;
            text-align: center;
        }
    </style>
</head>
<body>
<div id="main">
    <div>
        <span class="boxs">	注册成功!</span>
    </div>
    <div>
        <span class="boxs">
            本页面将在<span id="Time">5</span>秒之后跳转到登录页面!
        </span>
    </div>
    <div>
        <span style="" id="Font">
            如未成功跳转,请<a href="javascript: window.location.href='https://www.baidu.com'">点击这里</a>
        </span>
    </div>
</div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值