function timer(time,max) {
if(time-1>=0) {
--time;
$("#timer2").html(Math.ceil(time/100));
pix = Math.round((time/max)*100);
document.getElementById('timer').style.width = pix+"%";
setTimeout("timer("+time+","+max+")",10);
}
}
那是Javascript。
You have <font style='color: #ff0' id='timer2'><?PHP echo $time; ?></font> seconds left until you can skill again<br>
<div style='background-color: black; width: 100px;'>
<div style='background-color: #ffd700; text-align: center; width: 100%' id='timer'>
</div>
</div>
<script>
timer(<?PHP echo $time*100; ?>,<?PHP echo $time*100; ?>);
</script>
基本上,时间可以是 X 秒。计时器每 10 毫秒运行一次,因此条形图看起来很平滑。问题是,当您离开该选项卡时,它会停止移动。有没有办法治愈这段代码来做到这一点?
谢谢!