javascript - Angularjs - Fire Http Post On Tab/Browser Close -


goal

i using idle timer found on github see if users afk webapp. https://github.com/hackedbychinese/ng-idle

it works , have no issues it. unable set users away if close browser or leave site.

therefore need way detect if navigate site not apart of site , if close browser or tab site on.

code below works still happens if redirect different page on site

    var exitevent = window.attachevent || window.addeventlistener;     var chkevent = window.attachevent ? 'onbeforeunload' : 'beforeunload';       exitevent(chkevent, function (e) {         dashboardservice.setidle();         var confirmationmessage = ' ';           (e || window.event).returnvalue = "are sure you'd close page?";         return confirmationmessage;     }); 

code below doesn't work

    $window.onbeforeunload = function () {         dashboardservice.setidle();     } 

could not find way tell if browser has closed user.

instead timeout created disassoicate user on backend of application


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -