我需要有关 JavaScript 的帮助。我正在使用此代码来获取程序的执行时间:
if(seconds == sec){alert(sec);}
function countdown(element) {
interval = setInterval(function() {
var el = document.getElementById(element);
if(seconds == 0) {
//alert(seconds);
if(minutes == 0) {
el.innerHTML = "00 : 00";
alert("Sorry, you have exceeded our booking time and your order has been cancelled. We are afraid you have to start over!",null,'');
clearInterval(interval);
ajax_load_image();
window.location.href='movies.html';
return;
} else {
minutes--;
seconds = 60;
}
}
if(minutes > 0) {
var minute_text = minutes+(minutes > 1 ? ' ' : ' ');
} else {
var minute_text = '0';
}
if(minute_text<0)
{
$('#countdown').css('color','red');
}
var second_text =seconds > 1 ? '' : '';
if(minute_text=='')
{
el.innerHTML ='0 : '+seconds;
}
else
{
if(seconds<10)
{
seconds='0'+seconds;
}
el.innerHTML = '0'+minute_text + ' : ' + seconds + ' ' + second_text + ' Min';
}
seconds--;
}, 1000);
}
当我锁定手机时,计时器会自动停止。当我锁定手机时,我该怎么做才能运行计时器。帮我。