shricharan bhat shricharan bhat - 5 months ago 8
AngularJS Question

How to close an event on navigating to different Tab or window

Suppose i am trying to make an portal for Online Test on my angular application, And i want close and end the session on navigating (opening new tab or window) to different Window. Is it possible to do so with any JavaScript or J Query function?
Or to restrict users from opening new screen Unless they submit the answers.

Answer

You should try blur event:

$(window).blur(function() {
    // end session
});