且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测浏览器关闭/导航到其他页面并注销的***方式

更新时间:2022-11-18 16:55:56

看起来GWT确实有这样的事件。

ClosingEvent



看起来您需要实施 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.

ClosingEvent.

Looks like you need to implement a ClosingHandler