简体   繁体   中英

jQuery timer - idle timeout

I am trying to implement Eric Hynds' jquery-idle-timeout dialog which works fine without any issues. But how can I timer / idle timeout to get work even during computer sleep or phone screen-off .

Currently timer getting paused if computer sleeps or phone screen-off.

Do I need to add any specific jquery events apart from mousemove keydown DOMMouseScroll mousewheel mousedown ?

Any help would be highly appreciated.

You can show the dialog box when the computer sleeps but you can check for the interval when computer wakes up something like this

var oldTime = Date.now();

var expire = 50000; //expire time in ms

var interval = 5000; //interval time in ms

setInterval(function() 
{
   var newTime = Date.now(),
   if (newTime - oldTime > interval+expire)
   {
      //call the expire function

   }
   oldTime = newTime
}, interval);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM