jquery - Capture user Idling using javascript -
our site has ifame links different content sites used online exams exams in content pages running 3+ hours exam guard there prevent users doing other stuff while doing exams
the problem once user completed exams on 3+hrs , come parent site (our site) has session time out issue in parent page, (parent site session time out set 180min )
as solution have implemented following jquery
var to; $(document).ready(function () { = settimeout("timeout()", 10000); }); function timeout() { $.ajax({ type: "post", url: "keepalivedummy.aspx", success: function () { = settimeout("timeout()", 10000); } }); };
now problem if 1 user open parent site , go away keep session unwantedly,
any suggestion capture idle time?
we can use "mousemove" event , see whether user active or not.
i have used below code test whether user idle time reached maximum idle time.
function checkidletimeout() { useridletime++; if( useridletime >= maxidletime ) { alert("reached max user idle time"); clearinterval(intvl); } $("#output").html( "useridletime: " + useridletime ); }
i have provided sample demo, max idle time set 5 seconds.
demo @ jsfiddle demo
Comments
Post a Comment