I am creating a function that prevent the user when he reload the page or press a back space or press back button of Browser . i try the following code..

$wnd.beforeunload=function()
 {
    return "hello";
 }

it is working with simply java script but not in jsni . i also used

Window.addWindowClosingHandler(new ClosingHandler()
{
    @Override
    public void onWindowClosing(ClosingEvent event)
    {
        event.setMessage("Are you sure?");
    }
});

this is working with page refreh and closing, but not working with back button of browser and backspace ...pleace HELP..

有帮助吗?

解决方案

I have already posted an answer in the same context.

Please have a look at promt user on backspace and browser backbutton in gwt for complete code with screenshots.

Try with any option:

  • History.addValueChangeHandler
  • WindowClosingHandler
  • Event.addNativePreviewHandler
  • $wnd.onbeforeunload
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top