Why the OnBeforeUnload doesn't intercept the back button in my GWT app?

后端 未结 1 466
太阳男子
太阳男子 2021-01-24 12:34

I have a hook on the beforeUnload event. If i try to click on a link, reload or close the tab or the navigator, the app ask for confirmation before leaving. That\'s the desired

相关标签:
1条回答
  • 2021-01-24 12:39

    As long as you stay within your app, because it's a single-page app, it doesn't by definition unload, so there's no beforeunload event.

    When using Places, the equivalent is the PlaceChangeRequestEvent dispatched by the PlaceController on the EventBus. This event is also dispatched in beforeunload BTW, and is the basis for the mayStop() handling in Activities.

    Outside GWT, in the JS world, an equivalent would be hashchange and/or popstate, depending on your PlaceHistoryHandler.Historian implementation (the default one uses History.newItem(), so that would be hashchange).

    0 讨论(0)
提交回复
热议问题