javascript 倒计时代码

    <script language="javascript" type="text/javascript">
        var interval = 1000;
        function ShowCountDown(year, month, day, house,divname)
        {
            var now = new Date();
            var endDate = new Date(year, month - 1, day,house);
            var leftTime = endDate.getTime() - now.getTime();
            var leftsecond = parseInt(leftTime / 1000);
    //var day1=parseInt(leftsecond/(24*60*60*6)); 
            var day1 = Math.floor(leftsecond / (60 * 60 * 24));
            var hour = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600);
            var minute = Math.floor((leftsecond - day1 * 24 * 60 * 60 - hour * 3600) / 60);
            var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60);
            var cc = document.getElementById(divname);
            cc.innerHTML = "<strong>" + day1 + "</strong>天<strong>" + hour + "</strong>小时<strong>" + minute + "</strong>分<strong>" + second + "</strong>秒";
        }
        window.setInterval(function() {
            ShowCountDown(2014,8,15, 23,'divdown');  //此处调整倒计时时间。
        }, interval);
    </script> 

直接可用DIV调用代码如下:

<span id="divdown"></span>

文章收集于某网站倒计时代码。

posted @ 2014-07-31 11:22  井哥  阅读(268)  评论(0编辑  收藏  举报

友情链接 哈尔滨seo 紫砂壶 虾米