<div>
        <h2>恭喜您,支付成功</h2>
        <span id="jumpTo">10</span>秒后自动返回首页
        <p><button>立即返回</button></p>
</div>


<script>
    // 逻辑:加载页面时,应该触发定时器 10s
    window.onload = function(){
        let timer = 10;
        setInterval(()=>{
            timer--;
            document.getElementById('jumpTo').innerText = timer;

    //时间结束后跳转

            if(timer==0){
                location.href = 'https://jinwen01.ke.qq.com';
            }
        },1000);
    }

    //点击直接跳转

    document.getElementsByTagName('button')[0].onclick = function(){
        location.href = 'https://jinwen01.ke.qq.com';
    }
</script> 

<style>
    div{
        margin:0 auto;
        width: 500px;
    }
    #jumpTo{
        color: red;
        font-size: 30px;
    }
</style>

By lxcss

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注