actually I am making a testing program.so I don't want the candidate to search google for the answers. So what I want to do is if they open another tab or another browser during the test time, they will be redirected to a page saying you cheated. How can I achieve this?
Asked
Active
Viewed 43 times
-1
-
Have you tried anything at all yet? Please put forth some effort to try, and we'll help you once you have some code written. – kittykittybangbang Jun 27 '15 at 02:02
-
_“How can I achieve this?”_ – not at all; at least not reliably. Plus, the browser window might get out of focus for any number of reasons … let me just click somewhere else, f.e. to mute my music player, because i want to focus all my attention on this awesome test … wait, what, “I cheated”? YGTBKM – CBroe Jun 27 '15 at 02:04
2 Answers
1
If you have:
<textarea id="dontcheat"></textarea>
You can use
$("#dontcheat").focusout(function(){
window.location.href = "youCheated.html"
});
Snippet
var cheatCount = 0;
$("#swiperNoSwiping").focusout(function() {
cheatCount++;
$("#cheatCount").text(cheatCount);
});
I'm not certain about cross-browser compatibility, but on Chrome at least the focusout
event fires when you:
- Click outside the text box
- Switch to another tab
- Minimise the window
However, anyone can easily bypass this if JS is disabled or through Inspect Element on Chrome.

Huey
- 5,110
- 6
- 32
- 44
-
It's a MCQ based test so I have only radio buttons. how to do that with radio buttons? – Anuran Barman Jun 27 '15 at 02:07
-
You could use `$(window).blur` in that case. [This question](http://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active) might be a good reference. – Huey Jun 27 '15 at 02:12
0
you need to create proxy for this, if you want to restrict access to any site while the test, you need that all computers in the network will pass through a gateway that you can be filter or change the packet, is more low level that you think...

Proxytype
- 712
- 7
- 18