简易5秒倒计时跳转特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>5秒倒计时跳转</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
            flex-direction: column;
        }
        .countdown-container {
            text-align: center;
            padding: 30px;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
        }
        .countdown {
            font-size: 48px;
            font-weight: bold;
            color: #ff5722;
            margin: 20px 0;
        }
        .sponsor {
            margin-top: 20px;
            font-size: 14px;
            color: #666;
        }
        .sponsor a {
            color: #2196F3;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="countdown-container">
        <h1>即将跳转到目标页面</h1>
        <div class="countdown" id="countdown">5</div>
        <p>页面将在 <span id="seconds">5</span> 秒后自动跳转...</p>
    

        <div class="sponsor">

        </div>
    </div>

    <script>
        let seconds = 5;
        const countdownElement = document.getElementById('countdown');
        const secondsElement = document.getElementById('seconds');
        const manualLink = document.getElementById('manualLink');

        // 倒计时函数
        function updateCountdown() {
            seconds--;
            countdownElement.textContent = seconds;
            secondsElement.textContent = seconds;

            if (seconds <= 0) {
                // 跳转到目标页面 - www.9pk.homes
                window.location.href = "http://www.baidu.com";
            } else {
                setTimeout(updateCountdown, 1000);
            }
        }

        // 开始倒计时
        setTimeout(updateCountdown, 1000);

        // 手动跳转链接
        manualLink.addEventListener('click', function(e) {
            e.preventDefault();
            window.location.href = "http://www.baidu.com";
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值