Reputation: 1765
I am building an examination app, in which i need users to stay on the app and answer some questions. I need to monitor when they fail to do so, like opening a new tab or browser to search for answers. Also when they minimize the app window etc. So is there any way to do this in jquery. Please don't down vote this question as I have searched for similar question on this site for answers.
Something like when mouse does not hover over body element of the document.?
Upvotes: 1
Views: 444
Reputation: 171690
For what it's worth, and I'm not going to check this cross browser..leave it to you, but some of the window events may be of help.
Try these out. Using Firefox they will trigger on change of browser tab and minimize of window if mouse has been active in document to give window focus. You could dig deep into other window events available and see if you can come up with enough to make it work for you, or at least you will have expanded your due diligence
$(window).blur(function(){
console.log('blur')
}).focus(function(){
console.log('focus')
});
Update your code findings... is a bit interesting
Upvotes: 1
Reputation: 31
I dont think so with jQuery alone as you dont have enough control over the Browser with JS.
What you can do though is use some software/browser designed to run in Kiosks as they have alot of the same requirements but might not have been immediately obvious to you.
Upvotes: 0
Reputation: 449613
This is by design not possible - it would be a massive security problem if JavaScript could to stuff like this outside its sandbox.
You will need full control over the client machine to enforce something like this, using a client-side application that can occupy the full screen, lock task switching, etc.... it's a lot of programming work, would probably have to be done specifically for every OS, and will never be 100% reliable. Plus even a 100% solution is trivial to circumvent by having a second computer nearby.
The best you can do in a web site context is implement some safeguards, like time limits, monitoring keyboard activity inside the page and making sure it's constant, and such. What is appropriate here is dictated by your real-world situation, consider adding more information about it.
Upvotes: 1
Reputation: 6499
Shot answer:
No, there is not way to do so!
Long answer:
You can't consider that user has minimized the browser for searching answers. It could be another thing popping up in his computer that made him do so.
Having such control to user's computer can make user's life hell. Developers are trying to make users life easier and not uncomfortable.
And as you the know the answer again is, you can't do so :-)
Upvotes: 0