我正在使用倒数计时器在时钟降至 0 时显示链接。有没有办法可以在时钟达到 0 时调用 .php 文件而不是显示链接?
这是我正在使用的代码。
<!--START COUNTDOWN TIMER SCRIPT-->
<br />
<script type="text/javascript">
window.onload = function()
{
countDown('my_div1', '<a href="cdtl.html">Hello 1</a>', 720);
}
function countDown(elID, output, seconds)
{
var elem = document.getElementById(elID),
start = new Date().getTime(), end = start+seconds*1000,
timer = setInterval(function() {
var now = new Date().getTime(), timeleft = end-now, timeparts;
if( timeleft < 0) {
elem.innerHTML = output;
clearInterval(timer);
}
else {
timeparts = [Math.floor(timeleft/60000),Math.floor(timeleft/1000)%60];
if( timeparts[1] < 10) timeparts[1] = "0"+timeparts[1];
elem.innerHTML = "Time left: "+timeparts[0]+":"+timeparts[1];
}
} ,250); // the lower this number, the more accurate the timer. 250 recommended
}
</script>
<center>
<div id="my_div1"></div>
</center>
<!--END COUNTDOWN TIMER SCRIPT-->