固定时间无操作跳转(网站跳转到登录页面)

来源:互联网 发布:淘宝买万艾可处方单 编辑:程序博客网 时间:2024/06/05 13:21

  50分钟无操作退出网站  

 //定时跳转

        var x;
        window.onload = init; function init() { //设置,页面载入完毕之后,1秒不懂鼠标就页面就会跳转
            x = setTimeout(function () {
                $.Send("Core/Leave", {}, function (result) {
                    if (result.success) {
                        window.location.href = decodeURI(result.msg);
                    }
                    else {
                        parent.layer.msg(decodeURI(result.msg));
                    }
                });
            }, 50 * 60000); //鼠标在网页上移动调用moved函数
            document.onmousemove = moved;
        } function moved() { //既然鼠标移动了,取消页面跳转
            clearTimeout(x); //从现在开始重新计时,如果到了1秒还是要跳转
            x = setTimeout(function () {
                $.Send("Core/Leave", {}, function (result) {
                    if (result.success) {
                        window.location.href = decodeURI(result.msg);
                    }
                    else {
                        parent.layer.msg(decodeURI(result.msg));
                    }
                });
            }, 50 * 60000);
        }
0 0