A simple question that I just can't find an answer for. I want to stop a periodic AJAX call when the user has wandered away and locked their PC. I don't need it to be every OS patible or every browser (Chrome and IE would be good).
setInterval just doesn't seem to stop when locked and AJAX is also not prevented. The visibilitychange event seems to think that the tab is visible unless you switch to another tab.
I have stated javascript, but I only care that it can be done within the browser without asking the user.
Edge does seem to indicate it is hidden when locked, so I'm ok with that browser.
Thanks
A simple question that I just can't find an answer for. I want to stop a periodic AJAX call when the user has wandered away and locked their PC. I don't need it to be every OS patible or every browser (Chrome and IE would be good).
setInterval just doesn't seem to stop when locked and AJAX is also not prevented. The visibilitychange event seems to think that the tab is visible unless you switch to another tab.
I have stated javascript, but I only care that it can be done within the browser without asking the user.
Edge does seem to indicate it is hidden when locked, so I'm ok with that browser.
Thanks
Share Improve this question asked Nov 26, 2015 at 0:18 JonoTJonoT 731 silver badge6 bronze badges 7- 2 In your javascript it is not possible to detect if the OS UI has locked. You would need to write a browser plugin to do this. – bhspencer Commented Nov 26, 2015 at 0:20
- Rats, I was just trying to edit my post to say that I didn't want to use chrome.idle in an extension but you beat me to it! Thanks anyway – JonoT Commented Nov 26, 2015 at 0:22
- @bhspencer I suggest posting that as an answer – djechlin Commented Nov 26, 2015 at 0:22
- @gladsocc I'm inclined to agree with you – JonoT Commented Nov 26, 2015 at 0:23
- You can detect when the window has lost focus, which is close enough to idle. – zzzzBov Commented Nov 26, 2015 at 0:24
2 Answers
Reset to default 3You can use the Idle.js library to detect if the user is looking away from the browser window or is inactive (his input devices are inactive).
Whatever the case, there's not a reliable way to get the OS or the screen saver state from the browser
In your javascript it is not possible to detect if the OS UI has locked. The browser sand box prevents this kind of access to OS resources for security reasons. You would need to write a browser plugin to do this.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744721380a4589930.html
评论列表(0条)