Under my umbrella.

SKII

Less is more.

自动跳转至首页(Java Script)

自动跳转至首页(Java Script)

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>Java Script Test Place</title>

    <style>
        p{
            text-align: center;
        }
        #count{
            color: red;
        }
    </style>
</head>
<body>
    <p><span id="count">10</span>秒后自动跳转至首页!</p>

    <script>
        var second=10;
        var count=document.getElementById("count");
        function countDown(){
            if(second<=0){
                location.href="https://www.baidu.com";
                return;
            }
            second--;
            count.innerHTML=second.toString();
        }
        window.setInterval(countDown, 1*1000);
    </script>
</body>
</html>
posted @ 2020-03-15 20:05  NLYang  阅读(412)  评论(0编辑  收藏  举报