2
我寫的方法對mouse click
,KEYUP和keypress
復位超時,但我意識到,它不會對輸入字段檢查,所以當我積極字段會超時打字。 這裏是我的代碼:超時時間計數未檢測到輸入字段
var idleInterval = setInterval(timerIncrement, 10000);
var idleTime = 0;
$(document).ready(function() {
//Increment the idle time counter every minute.
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e) {
idleTime = 0;
});
$(this).keyup(function (e) {
idleTime = 0;
});
});
function timerIncrement() {
idleTime = idleTime + 1;
if (idleTime > 4) {
window.location.replace('/timeout.aspx');
}
}
@ PredatorIWD我想你的建議,它實際上與鼠標移動工作,它復位定時器,而與輸入字段內按鍵,好像oncewhen是按鍵事件輸入區域內從文檔中分離得到裏面。 – Mindan
@Mindan即使在輸入欄裏面也應該註冊它。也許你可以在這裏爲它提供html,或者搜索更多註冊所有按鍵的函數。 – PredatorIWD