倒计时脚本不适用于safari

时间:2016-01-19 15:52:57

标签: javascript safari countdowntimer

我有那个脚本并且它工作得很好但是遇到了safari和firefox的一些问题。 问题是NaN!

enter image description here

应该是:

enter image description here

var timediff=(this.targetdate-this.currentTime)/1000 //Differenza tra la data desiderata e quella corrente, in secondi
if (timediff<0){ 
this.timesup=true
this.container.innerHTML=this.formatresults()
return
}
var oneMinute=60 //minuti in secondi
var oneHour=60*60 //ore in secondi
var oneDay=60*60*24 //giorni in secondi
var dayfield=Math.floor(timediff/oneDay)
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
if (this.baseunit=="hours"){ 
hourfield=dayfield*24+hourfield
dayfield="n/a"
}
else if (this.baseunit=="minutes"){ 
minutefield=dayfield*24*60+hourfield*60+minutefield
dayfield=hourfield="n/a"
}
else if (this.baseunit=="seconds"){ 
var secondfield=timediff
dayfield=hourfield=minutefield="n/a"
}
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //Aggiorna ogni secondo
}

此部分应存储当前时间。

function formatresults(){
    if (this.timesup==false){//Se la data non è stata ancora raggiunta
        var displaystring=arguments[0]+" "+traddate+" "+arguments[1]+":"+arguments[2]+":"+arguments[3]
    } else { //se la data è stata raggiunta
        var displaystring="Data raggiunta"
    }
    return displaystring
}

还有结果打印的代码。我认为错误应该在本节中。

petid

解决方案? 它似乎只适用于chrome。

0 个答案:

没有答案