0

Is there any way to handle page refresh in JavaScript ? After browser close button is clicked my application should be logged out and after clicking on browser back button application should be logged out also.

garyh
  • 2,782
  • 1
  • 26
  • 28

2 Answers2

0

Try this snippet by clicking run and reload or backwards in your browser.

window.onbeforeunload = function(e) {
  //call your function
  return "Attention Reload"
};

Have a look at this eventHandler

Colin
  • 1,112
  • 1
  • 16
  • 27
0

Try This Answer This answer will help you out

Also this only shows how to access the back button functionality in cross browser, However in the scope of those functions, You can destroy your token or whatever to logout or you can directly use window.location.href, description of the same is given in Window.location.href

Hope that helps, Also if this does not solve specify more details in question that how are you logging out,

Thanks & Regards

Shohil Sethia

SHOHIL SETHIA
  • 2,187
  • 2
  • 17
  • 26