«

JavaScript制作倒计时页面,倒计时5秒跳转至六思逸官网

时间:2023-6-6 01:27     作者:六思逸     分类: JavaScript


效果图

JavaScript制作倒计时页面,倒计时5秒跳转至六思逸官网

完整代码

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>六思逸</title>
    <style>
        #box {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 200px;
            height: 200px;
            line-height: 200px;
            text-align: center;
            background-color: black;
            color: white;
            font-size: 50px;
            font-weight: bold;
            border-radius: 50%;
        }
    </style>
</head>
<!-- 制作一个倒计时5秒钟的页面,时间显示为0时跳转到六思逸) -->

<body>
    <div id="box"></div>
    <script>
        function box(num) {
            document.getElementById('box').innerHTML = num;
            let timer = window.setInterval(function () {
                num--;
                console.log(num)
                document.getElementById('box').innerHTML = num;
                if (num <= 0) {
                    window.location.href = 'https://www.6s1.cn/'
                    window.clearInterval(timer)
                }
            }, 1000);
        }
        box(5)
    </script>
</body>

</html>

标签: JavaScript 倒计时 页面制作 六思逸

版权所有:六思逸
文章标题:JavaScript制作倒计时页面,倒计时5秒跳转至六思逸官网
除非注明,文章均为 六思逸 原创,转载请注明作者和出处 六思逸

扫描二维码,在手机上阅读

推荐阅读: