检测浏览器关闭/导航到其他页面并注销的最佳方式 [英] Best way to detect browser closing/navigation to other page and do logout
问题描述
我在GWT中编写应用程序,我需要检测用户何时离开我的应用程序或关闭浏览器窗口(onUnload事件)并执行注销(会话失效和其他一些清理任务)。注销操作由一个servlet执行。
我正在通过挂钩onUnload()事件并打开一个指向注销servlet的新窗口来做到这一点。
有没有更好的方法来做到这一点?欢迎您提出任何其他建议。
看起来GWT确实有这样的事件。
看起来您需要实施 ClosingHandler
I am writing an application in GWT and I need to detect when a user navigates away from my application or when he closes the browser window (onUnload event) and do a logout (session invalidation and few other cleanup tasks). The logout action is performed by a servlet.
I am currently doing this by hooking into the onUnload() event and opening a new window pointed to the logout servlet.
Is there a better way to do this? Any other suggestions are welcome.
Looks like GWT does have an event for exactly this.
Looks like you need to implement a ClosingHandler
这篇关于检测浏览器关闭/导航到其他页面并注销的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!