js实现十分钟内在页面无任何操作,页面跳转至登陆页

    // 如果10分钟没有操作,退出到登录页
    var timer;
    function startTimer(){
        clearTimeout(timer);
        timer=setTimeout(function(){
            // 清空缓存和token
            $cookies.remove("access_token", { path: "/" });
            $cookies.remove("userName", { path: "/" });
            $cookies.remove("userId", { path: "/" });
            $cookies.remove("roleName", { path: "/" });
            $cookies.remove("userCount", { path: "/" });
            window.location.href = "/index.html"
        },10*60*1000);
    }
    document.onmousemove=document.onmousedown=startTimer
原文地址:https://www.cnblogs.com/yingzi1028/p/10565287.html