gpt4 book ai didi

javascript - IE 和 Firefox 中的 NaN 字符

转载 作者:行者123 更新时间:2023-12-02 17:22:10 24 4
gpt4 key购买 nike

这是我的 HTML 代码:

<ul class="countdown">
<li class="timer"><div id="days"></div><H1>Days</H1></li>
<li class="timer"><div id="hours"></div><H1>Hours</H1></li>
<li class="timer"><div id="mins"></div><H1>Minutes</H1></li>
<li class="timer"><div id="secs"></div><H1>Seconds</H1></li>
</ul>

这是 JS 代码,

var xmas = new Date("jule 2, 2014 00:01:00");
var now = new Date();
var timeDiff = xmas.getTime() - now.getTime();
if (timeDiff <= 0) {
clearTimeout(timer);
document.write("Christmas is here!");
// Run any code needed for countdown completion here
}
var seconds = Math.floor(timeDiff / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
hours %= 24;
minutes %= 60;
seconds %= 60;
document.getElementById("days").innerHTML = days;
document.getElementById("hours").innerHTML = hours;
document.getElementById("mins").innerHTML = minutes;
document.getElementById("secs").innerHTML = seconds;
var timer = setTimeout('cdtd()',1000);

结果在 Chrome 中工作,但 IE 和 Firefox 返回 NaN

最佳答案

我成功了。

现场示例:http://testnaman.neocities.org/quicktest2.html 。这不会是永久性的。

您需要更改:

var xmas = new Date("jule 2, 2014 00:01:00");

致:

var xmas = new Date("July 2, 2014 00:01:00");

看来 Firefox 不喜欢错误的拼写。

有关更多信息,请查看:new Date() is working in Chrome but not Firefox .

关于javascript - IE 和 Firefox 中的 NaN 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23845576/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com