📜  用于测试屏幕是否空闲的 javascript 代码 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:12.193000             🧑  作者: Mango

代码示例1
var inactivityTime = function () {
    var time;
    window.onload = resetTimer;
    // DOM Events
    document.onmousemove = resetTimer;
    document.onkeydown = resetTimer;

    function logout() {
        alert("You are now logged out.")
        //location.href = 'logout.html'
    }

    function resetTimer() {
        clearTimeout(time);
        time = setTimeout(logout, 3000)
        // 1000 milliseconds = 1 second
    }
};