我有一块JS正在通过php插入一些(秒)并为用户生成倒计时。它在Chrome中效果很好,但在Firefox中似乎总是为seconds_left设置零值。我错过了什么?
<script>
// variables for time units
var minutes, seconds;
var seconds_left = {COUNTDOWN};
// get tag element
var countdown = document.getElementById("countdown");
// update the tag with id "countdown" every 1 second
setInterval(function () {
minutes = parseInt(seconds_left / 60);
seconds = parseInt(seconds_left % 60);
// format countdown string + set tag value
if(seconds < 10) {
countdown.innerHTML = minutes + ":" + ("0" + seconds).slice(-2);
} else {
countdown.innerHTML = minutes + ":" + seconds;
}
if(seconds_left > 0){seconds_left--;}else{countdown.innerHTML = "NOW!";}
}, 999);
</script>