admin管理员组文章数量:1391960
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.
本文标签: How to detect desktop is locked in javascriptStack Overflow
版权声明:本文标题:How to detect desktop is locked in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744721379a2621715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论