I have two classes when navigating from one class to another created history. Now, I want to prompt the user by a confirm whether user wants to leave the page or not.Till now , I tried using Window.closingHandler()
in gwt
but its not working for backspace button and browser back button its only working on closing the entire browser or that particular page using cross. Its also working on reload.
I have also tried on Javascript and it worked perfect using onbeforeunload()
.
Here are the codes I used.
JAVASCRIPT:
window.onbeforeunload = function () {
return "Are you sure you wish to leave this delightful page?";
}
And the other code in gwt:
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(ClosingEvent event) {
event.setMessage("Do you wanna close?");
System.out.println("Closing...");
}
});
I want it to be done in gwt
.