天天看點

js 網頁實作計時器 監控滑鼠定時報警

通過調用startclock();pauseclock();stopclock()來控制計時器開始計算與暫停,從新計時等操作。注意調用次數。

var timeSpan = 1000; //設定時間步長,

var mued = 0; //檢測滑鼠多長時間為移動

var DefaultDuration = 120; //預設定時儲存時長

function clockon() {

    LearningSeconds++;

    thistime = LearningSeconds;

    var hours = parseInt(thistime / 3600);

    var minutes = parseInt((thistime - hours * 3600) / 60);

    var seconds = parseInt(thistime % 60);

    if (eval(hours) < 10) { hours = "0" + hours }

    if (eval(minutes) < 10) { minutes = "0" + minutes }

    if (seconds < 10) { seconds = "0" + seconds }

    thistime = hours + ":" + minutes + ":" + seconds

    if (document.all) {//火狐浏覽器不執行

        //bgclocknoshade.innerHTML = thistime

        spTime.innerHTML = thistime

    }

    else {

        $("#spTime").html(thistime);

    mued++; //記錄滑鼠為移動時間

    //    var timer = setTimeout("clockon()", timeSpan);

    if (mued >= 60) {//監控滑鼠為移動時間

        //timeSpan = 10000;

        //alert("好久沒有動了");

        mark = true;

        pauseclock();

        timeSpan = 1000;

    //自動儲存設定

    //監控是否可以進入考核//退回重做的必須重新學習

}