简体   繁体   English

JavaScript页面刷新问题

[英]JavaScript page refresh issue

Is there any way to handle page refresh in JavaScript ? 有什么方法可以处理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. 单击浏览器关闭按钮后,我的应用程序应注销,单击浏览器后退按钮后,应用程序也应注销。

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 看看这个eventHandler

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 这也仅显示了如何在跨浏览器中访问后退按钮功能,但是,在这些功能的范围内,您可以销毁令牌或注销的对象,也可以直接使用window.location.href ,其说明在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 肖希尔·塞提亚

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM