Question

I am making a program that is for a test. it uses a combination of jsp and servlet and using tomcat 7.0 . My requirement is to identify whenever the user switches the tab or opens a new window of the browser, so that he is unable to use any other resources while giving the test. I am planning to start a thread that continuously checks the focus of the user. What is the possible solution ?

No correct solution

OTHER TIPS

window.onblur works

<script>
    window.onblur = function() { 
    //your code
     };
    </script>

jQuery implementations:

$(window).blur(function(e) {
    // your code
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top