JS倒计时网页自动跳转代码

<title>JS倒计时网页自动跳转代码</title>  
<script language="JavaScript" type="text/javascript">
    function delayURL(url) {
        var delay = document.getElementById("time").innerHTML;
        if(delay > 0) {
            delay--;
            document.getElementById("time").innerHTML = delay;
        } else {
            window.top.location.href = url;
        }
       t = setTimeout("delayURL('" + url + "')", 1000);
    }
 
function stop1(){  
t && clearTimeout(t);
}
</script>
<span id="time" style="background: #00BFFF">1000</span>秒钟后自动跳转,如果不跳转,请点击下面的链接<a href="http://www.baidu.com">我的百度</a>
<input type="button" value="停止跳转" onclick="stop1();">
<script type="text/javascript">
delayURL("http://www.baidu.com");
</script>

 

posted @ 2016-03-23 15:27  侠岚之弋痕夕  阅读(160)  评论(0编辑  收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!