我们如何在GWT中使用onbefoerunload [英] how can we use onbefoerunload in GWT

查看:146
本文介绍了我们如何在GWT中使用onbefoerunload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一项功能,以防止用户重新加载页面或按下退格键或按下浏览器的后退按钮。

  $ wnd.beforeunload = function()
{
return你好;
}

它只使用java脚本,但不能使用jsni。我还用过

$ p $ Window.addWindowClosingHandler(新的ClosingHandler()
{
@Override
public void onWindowClosing(ClosingEvent event)
{
event.setMessage(Are you sure?);
}
});

这是与页面refreh和关闭,但不与浏览器和退格键的后退按钮一起工作。 .pleace HELP ..

解决方案

我已经在相同的上下文中发布了答案。


请查看


$ b $ -gwt?answertab = votes#tab-top> promt用户退格和浏览器后退gwt
b

尝试使用任何选项:




  • History.addValueChangeHandler

  • WindowClosingHandler

  • Event.addNativePreviewHandler

  • $ wnd.onbeforeunload


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

这篇关于我们如何在GWT中使用onbefoerunload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆