开发者

Detecting user inactivity on my website

What's the most simple way to detect user inactivity and ask him if he's there?

Basically, after 3 m开发者_开发技巧inutes of the user not clicking on anything on the site, I'd like to ask him if he's there. He click's the OK button of a prompt of sorts and the entire page reloads.

Is there a jQuery script for this?


Here is a jquery plugin "idleTime" that seems designed to do exactly what you need http://paulirish.com/2009/jquery-idletimer-plugin/

Demo

Here is a simple implementation:

$.idleTimer(10000);

$(document).bind("idle.idleTimer", function(){
    var reload = confirm("Refresh the Page?");
    if (reload){
        location.reload(true);
    }
    else{
        window.location = "Log Out Url";
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜