js倒计时,为什么不自动刷新时间?请高手指教

2025-06-28 07:16:59
推荐回答(2个)
回答1:




JS的TAB切换

function countdown ()
    {
    var end = new Date (2014, 10, 29, 3);
    var now = new Date ();
    
    var m = Math.round ((end - now) / 1000);
    var day = parseInt (m / 24 / 3600);
    var hours = parseInt ((m % (3600 * 24)) / 3600);
    var minutes = parseInt ((m % 3600) / 60);
    var seconds = m % 60;
    
    if (m < 0)
    {
    document.getElementById ("clock").innerHTML = '0';
    return;
    }
    document.getElementById ("clock").innerHTML = "离开始还剩" + day + "天" + hours + "小时" + minutes + "分钟" + seconds
            + "秒";
    setTimeout ('countdown()', 1000);
    }
    window.onload = function ()
    {
    countdown ();
    }





回答2:

你的countdown()方法呢