这是倒计时的代码。倒计时后,我需要显示一个超链接
<a id="hi" href="page.html">click</a>
给users.assuming今天的Eventtime,或者你可以在那里更改它。我怎么能这样做?
请更正此代码:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="days" style="display:inline;">00</p> Days
<p id="hours" style="display: inline;">00</p> Hrs
<p id="minutes" style="display: inline;">00 </p> Min
<p id="seconds" style="display: inline;">00</p> seconds Left
<div id="hi"></div>
<script type="text/javascript">
var timer;
function myLoop() {
var now = new Date();
var eventDate = new Date(2017, 9, 21,7,56);
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;
if(d>=0 && h>=0 && m>=0 && s>=0)
{
document.getElementById("days").textContent = d;
document.getElementById("hours").textContent = h;
document.getElementById("minutes").textContent = m;
document.getElementById("seconds").textContent = s;
if(d>=0 && h>=0 && m>=0 && s>=0)
{
timer= setTimeout(myLoop, 1000);
}
else
{
clearTimeout(timer);
document.getElementById('hi').innerHTML=
"<a id='hi'href='page.html'>click</a>";
}
}
}
myLoop();
</script>
</body>
</html>
那么如何在cleartimeout之后设置超链接。我在clearTimeout语句仍然不能正常工作之前尝试过。实际上,我必须在一个分区内显示这个锚标记,该分区在计数器超时后将分区重定向到给定的超链接。