0

我有某些倒数计时器代码,已修改如下:

<script language="JavaScript" type="text/JavaScript">
var Timer;
var TotalSeconds;
var timer_interval;
function CreateTimer(TimerID,Time) {
    Timer = document.getElementById(TimerID);
    window.TotalSeconds = getCookie('Times');
    if(!window.TotalSeconds){
            window.TotalSeconds = Time;
    }
    timer_interval=window.setTimeout(Ticker(),1000);
    window.clearTimeout(timer_interval);
    deleteCookie('Times');
    UpdateTimer();
    window.setTimeout(Ticker(), 1000);
}

 function UpdateTimer() {
    var Seconds = window.TotalSeconds;
    var Hours = Math.floor(Seconds / 3600);
    Seconds -= Hours * (3600);
    var Minutes = Math.floor(Seconds / 60);
    Seconds -= Minutes * (60);
    var TimeStr = LeadingZero(Hours) + ":" + LeadingZero(Minutes) + ":"+LeadingZero(Seconds);
    Timer.innerHTML = "&nbsp;&nbsp;&nbsp;Your Time Slot Temporary Blocked Will Last For : "+ TimeStr;
}

function Ticker() {
    if (window.TotalSeconds <= 0)
    {
            location.href="admin.jsp?action=zerosecond";
            window.clearTimeout(time_interval);
            deleteCookie('Time');
    }
    window.TotalSeconds -= 1;
    setCookie('Times', window.TotalSeconds, 1);
    UpdateTimer();
    window.setTimeout(Ticker(), 1000);
}

function LeadingZero(Time) {
    return (Time < 10) ? "0" + Time : + Time;
}

function setCookie(name,value,days) {
var expires;
if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    expires = "; expires="+date.toGMTString();
}
else {
    expires = "";
}
   document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
        c = c.substring(1,c.length);
    }
    if (c.indexOf(nameEQ) === 0) {
        return c.substring(nameEQ.length,c.length);
    }
 }
  return null;
}

function deleteCookie(name) {
     setCookie(name,"",-1);
}
</script>

它在前台进程上工作正常,但反之亦然。那么,如何将其转换为后台进程?提前致谢

4

0 回答 0