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 behavior.
But if click on the back button or the backspace outside an input, no confirmation.
At the beginning of the html :
window.onbeforeunload = function() {
if (confirmEnabled)
return "";
}
And i use the Gwt PlaceHistoryMapper.
What did i miss ? Where did i forgot to look ?
Thanks !
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
beforeunloadevent.When using Places, the equivalent is the
PlaceChangeRequestEventdispatched by thePlaceControlleron theEventBus. This event is also dispatched inbeforeunloadBTW, and is the basis for themayStop()handling in Activities.Outside GWT, in the JS world, an equivalent would be
hashchangeand/orpopstate, depending on yourPlaceHistoryHandler.Historianimplementation (the default one usesHistory.newItem(), so that would behashchange).