0

In my AngularJS application I use the Facebook SDK. When I use FB.logout() on the logout button click it works properly:

  $scope.logout = function() { 
    FB.logout() 
  }

But I also want to logout from Facebook on window close. I do the following:

  $window.onbeforeunload = function() {
    FB.logout()
   }

As you can see I do the same in both cases. However, second one does not work.

Could someone tell me, why? And how to make it work? Thanks!

Sudo
  • 49
  • 1
  • 8

1 Answers1

0

You need to return null from onbeforeunload function. As mentioned here

So this should work.

$window.onbeforeunload = function() {
   FB.logout()
   return null;
}
Community
  • 1
  • 1
Moin
  • 1,087
  • 1
  • 9
  • 19