how can we use onbefoerunload in GWT

回眸只為那壹抹淺笑 提交于 2019-12-11 09:30:25

问题


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..


回答1:


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


来源:https://stackoverflow.com/questions/23291626/how-can-we-use-onbefoerunload-in-gwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!