js 简单倒计时

<html>
<head>
    <meta http-equiv="content-type" content="text/html" charset="utf-8">
</head>
<body>
页面将在<span id='remaining_time'></span>秒后自动跳转...
</body>
<script type="text/javascript">
var remaining_time = document.getElementById('remaining_time');
var t = 6;
function changeTime(){
    t--;
    remaining_time.innerHTML="&nbsp;"+t+"&nbsp;";
    if(t==0){
            window.location.href = 'http://www.baidu.com';
            return;
    }
    setTimeout('changeTime()', 1000);
}
changeTime();
</script>
</html> 

posted on 2013-12-07 12:12  小刈  阅读(185)  评论(0编辑  收藏  举报

导航