0

I have an online exam app but I need to prevent cheating how I could set a feature to my app expire content of exam when student goes to another tab please any Idea and suggestion

  • Check jQuery `unload()` function https://api.jquery.com/unload/ – A. Iglesias Oct 19 '17 at 19:27
  • Possible duplicate of [Is there a way to detect if a browser window is not currently active?](https://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active) – Alex Dovzhanyn Oct 19 '17 at 19:27
  • 1
    You can't, not reliably at least: Any solution that relies on the client can be manipulated by the client. – jeroen Oct 19 '17 at 19:40
  • 1
    "Ah, you don't let me switch to other windows during the exam? That's OK, I'll just use my cell phone." - There's really no way to do this reliably without having a completely controlled environment. – Mike Oct 19 '17 at 19:54

1 Answers1

1

You can determine if a tab or window is active by attaching a blur / focus event listener to window.

in jQuery it would be

$(window).focus(function() {
    //do something
});

$(window).blur(function() {
    //do something
});