如果在带有对话框的页面上没有发现任何活动,则自动退出


Automatic log-out if no activity found on page with dialog box

这是我的工作脚本,我也在这个网站上发现,空闲时间到期后,警报消息将弹出,它将直接到特定的页面。

然而,我想做的是空闲时间到期后,它会调用一个对话框,用户可以选择"保持登录"或"退出"按钮。如何用javascript设置对话框并调用它?对不起,我只是个新手。谢谢!

<script type="text/javascript">
var IDLE_TIMEOUT = 5; //seconds
var _idleSecondsCounter = 0;
document.onclick = function() {
    _idleSecondsCounter = 0;
};
document.onmousemove = function() {
    _idleSecondsCounter = 0;
};
document.onkeypress = function() {
    _idleSecondsCounter = 0;
};
window.setInterval(CheckIdleTime, 1000);
function CheckIdleTime() {
    _idleSecondsCounter++;
    var oPanel = document.getElementById("SecondsUntilExpire");
    if (oPanel)
        oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
    if (_idleSecondsCounter >= IDLE_TIMEOUT) {
        //alert("Time expired!");
        //document.location.href = "logout.html";
        CALL_A_DIALOG_BOX()

    }
}

如果您可以使用jQuery,请使用http://jqueryui.com/dialog/#modal-confirmation