简体   繁体   中英

Crosswalk onJsBeforeUnload counterpart

Is there a method wherein I can override the onJsBeforeUnload in XWalkUIClient like this in WebChromeClient?

      @Override
      public boolean onJsBeforeUnload(WebView view, String url, String message, final JsResult result) {
        new Thread(new Runnable() {
          @Override
          public void run() {
            handler.post(new Runnable() {
              @Override
              public void run() {
                result.confirm();
              }
            });
          }
        }).start();

        return true;
      }

I'm trying to use Crosswalk's onJsPrompt and onJsAlert but I have no success in getting the result of onJsBeforeUnload.

Thanks!

Apparently I haven't tried onJavascriptModalDialog. I was able to imitate onJsbeforeUnload's behavior using

  @Override
  public boolean onJavascriptModalDialog(XWalkView view, JavascriptMessageType type, String url, String message, String defaultValue, final XWalkJavascriptResult result) {
        new Thread(new Runnable() {
          @Override
          public void run() {
            handler.post(new Runnable() {
              @Override
              public void run() {
                result.confirm();
              }
            });
          }
        }).start();

        return true;
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM