<script type="text/javascript">
function countDown(secs,elem){
var element = document.getElementById(elem);
element.innerHTML = "Please wait for "+secs+" seconds";
if(secs<1){
clearTimeout(timer);
element.innerHTML = '<h2>Countdown Complete!</h2>';
element.innerHTML += '<a href="'.$url.'">Click here now</a>';
}
secs--;
var timer = setTimeout ('countDown('+secs+',"'+elem+'")',1000)
}
</script>
<div id="status"></div>
<script type="text/javascript">countDown(10,"status"); </script>
答案 0 :(得分:3)
您将Javascript和PHP混合起来,而不告诉websever使用哪一个。
更改此行:
element.innerHTML += '<a href="'.$url.'">Click here now</a>';
到
element.innerHTML += '<a href="<?php echo $url ?>">Click here now</a>';
在此调用之前,确保您实际上正在设置该php值。