【发布时间】:2015-12-23 09:20:44
【问题描述】:
你好,我正在编写一个代码用于自动注销大约 20 分钟的不活动状态,它应该与键盘和鼠标交互,我有以下代码,它适用于大多数功能,但它不会重置鼠标移动的计时器和键盘活动。
var timoutWarning = 9000; // Display warning in 14 Mins.
var timoutNow = 9000; // Warning has been shown, give the user 1 minute to interact
var logoutUrl = 'logout.php'; // URL to logout page.
var warningTimer;
var timeoutTimer;
// Start warning timer.
function StartWarningTimer() {
warningTimer = setTimeout("IdleWarning()", timoutWarning);
}
// Reset timers.
function ResetTimeOutTimer() {
clearTimeout(timeoutTimer);
StartWarningTimer();
$("#timeout").hide();
}
// Show idle timeout warning dialog.
function IdleWarning() {
clearTimeout(warningTimer);
timeoutTimer = setTimeout("IdleTimeout()", timoutNow);
$("#timeout").show();
}
// Logout the user.
function IdleTimeout() {
window.location = logoutUrl;
}
$( document ).ready(function() {
StartWarningTimer();
});
$('html').mousemove(function() {
ResetTimeOutTimer();
});
我希望代码应该通过鼠标移动和键盘按下来吸引 感谢您提供各种帮助,请给我一些建议
【问题讨论】:
-
请对您的标题进行拼写检查。
标签: javascript timer