0

I want to trigger logout when I close any tab of my application. I tried $(window).on('unload', logout); and $(window).on('onbeforeunload', logout); That works fine but events also triggered when I reload page. How can I prevent this on reload? Before asking I found some options like event.currentTarget.performance.navigation.type but no posibility to separate reload and close in this way. Is there any opputurnity to trigger logout only on tab closed?

MolecularMan
  • 227
  • 2
  • 16

1 Answers1

0

As per here Is there a way in javascript to detect if the unload event is caused via a refresh, the back button, or closing the browser? there is no way to detect the difference. Even if you could there would be other circumstances where it wouldn't work.

CumminUp07
  • 1,936
  • 1
  • 8
  • 21