你好我有这个代码在chrome中工作,但是在firefox中由于某些原因不起作用我得到NaN
值的输出。我读过有关Math
函数有错误的内容。
同样在线我看到document.getElementById("days").innerText = d;
在Firefox中遇到了一些麻烦,所以也许我在做错了吗?
所以最终的问题是如何让它在firefox中运行?
<div id="dueDate-counter">
<table>
<tr>
<td>days</td>
<td>hrs</td>
<td>mns</td>
<td>secs</td>
</tr>
<tr>
<td id="days"></td>
<td id="hours"></td>
<td id="minutes"></td>
<td id="seconds"></td>
</tr>
</table>
<script type="text/javascript">
function countdown() {
var now = new Date();
var eventDate = new Date("<%= reservation.due_date %>");
<%= puts "here is reservation !!!!!!!" %>;
<%= puts "#{reservation.due_date}" %>;
var currentTime = now.getTime();
var eventTime = eventDate.getTime();
var remTime = eventTime - currentTime;
var s = Math.floor(remTime / 1000);
var m = Math.floor(s / 60);
var h = Math.floor(m / 60);
var d = Math.floor(h / 24);
h %= 24;
m %= 60;
s %= 60;
h = (h < 10) ? "0" + h : h;
m = (m < 10) ? "0" + m : m;
s = (s < 10) ? "0" + s : s;
document.getElementById("days").textContent = d;
document.getElementById("days").innerText = d;
document.getElementById("hours").textContent = h;
document.getElementById("minutes").textContent = m;
document.getElementById("seconds").textContent = s;
setTimeout(countdown, 1000);
}
countdown();
</script>
</div>
这是我的计数器的错误