Timer在布尔值中不起作用

时间:2013-07-18 21:08:37

标签: javascript

我的计时器有问题 -

var myTimer = function () {
    var d = Date.now();
    // var t=d.toLocaleTimeString();
    var timerSeconds = Math.round((od - d) / 1000);
    document.getElementById("timer").innerHTML = "Time left for this tour:" + timerSeconds;
    if (timerSeconds > 0) {
        setTimeout(arguments.callee, 1000);
    } else {
        finTour();
    }
};
myTimer();

它调用此函数:

var finTour = function () {
    deleteCartes();
    randomCell();
    od = Date.now() + 5000;
    myTimer();
    window.setTimeout(function () {
        tourOfComp();
    }, 5000)

    var tourOfComp = function () {

        for (var i = 0; i < 12; i++) {
            if (document.getElementsByTagName("td")[i].style.backgroundColor == "aqua") {
                document.getElementsByTagName("td")[i].firstChild.data = cartes[prochaineCarte++]
            }
        }
        for (var j = 0; j < 12; j++) {
            if (document.getElementsByTagName("td")[j].style.backgroundColor == "aqua")
                document.getElementsByTagName("td")[j].style.backgroundColor = "";
        }
        for (var k = 0; k < 3; k++) {
            tab[k].value = "";
        }
        od = Date.now() + timeFixe;
        myTimer();
    };

问题是当我修复时间20时,它会调用这两个最后一个函数,时间总是为5而且从来没有20似乎它没有更新时间,但只重复这个:

window.setTimeout(function ()
{
 tourOfComp();
},5000)

0 个答案:

没有答案