• 懒鸟飞:精品网站源码、帝国cms模板专业分享平台

js实现5秒倒计时后跳转页面

<script type="text/javascript">
        function countDown(secs, surl) {
            var jumpTo = document.getElementById('jumpTo');
            jumpTo.innerHTML = secs;
            if (--secs > 0) {
                setTimeout("countDown(" + secs + ",'" + surl + "')", 1000);
            }
            else {
                location.href = surl;
            }
        }     
</script>


使用方法:
 
<div>发生错误,<span id="jumpTo">5</span>秒后自动跳转到首页,返回后请联系客服!</div>
<script type="text/javascript">
countDown(5, '/index.html');
</script>
 
QQ在线咨询
QQ客服
淘宝官网