• <i id='3XCT4'><tr id='3XCT4'><dt id='3XCT4'><q id='3XCT4'><span id='3XCT4'><b id='3XCT4'><form id='3XCT4'><ins id='3XCT4'></ins><ul id='3XCT4'></ul><sub id='3XCT4'></sub></form><legend id='3XCT4'></legend><bdo id='3XCT4'><pre id='3XCT4'><center id='3XCT4'></center></pre></bdo></b><th id='3XCT4'></th></span></q></dt></tr></i><div id='3XCT4'><tfoot id='3XCT4'></tfoot><dl id='3XCT4'><fieldset id='3XCT4'></fieldset></dl></div>
    <legend id='3XCT4'><style id='3XCT4'><dir id='3XCT4'><q id='3XCT4'></q></dir></style></legend>

    <tfoot id='3XCT4'></tfoot>

    <small id='3XCT4'></small><noframes id='3XCT4'>

    • <bdo id='3XCT4'></bdo><ul id='3XCT4'></ul>

        可能的 WebView OnCreateWindow 制作弹出窗口(对话框样式)?像安卓浏览器

        时间:2024-04-14

            • <bdo id='r0MYn'></bdo><ul id='r0MYn'></ul>

              <small id='r0MYn'></small><noframes id='r0MYn'>

                  <tbody id='r0MYn'></tbody>
              • <legend id='r0MYn'><style id='r0MYn'><dir id='r0MYn'><q id='r0MYn'></q></dir></style></legend>
              • <tfoot id='r0MYn'></tfoot>
                <i id='r0MYn'><tr id='r0MYn'><dt id='r0MYn'><q id='r0MYn'><span id='r0MYn'><b id='r0MYn'><form id='r0MYn'><ins id='r0MYn'></ins><ul id='r0MYn'></ul><sub id='r0MYn'></sub></form><legend id='r0MYn'></legend><bdo id='r0MYn'><pre id='r0MYn'><center id='r0MYn'></center></pre></bdo></b><th id='r0MYn'></th></span></q></dt></tr></i><div id='r0MYn'><tfoot id='r0MYn'></tfoot><dl id='r0MYn'><fieldset id='r0MYn'></fieldset></dl></div>

                  本文介绍了可能的 WebView OnCreateWindow 制作弹出窗口(对话框样式)?像安卓浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我在我的 web 视图中按下 ebay.com 上带有此代码的按钮时:

                  When I press a button with this code on ebay.com in my webview:

                  按钮的html:

                  html of button:

                  input id="addPicturesBtn" name="addPicturesBtn" type="button" value="Add pictures" class="button" onclick="ebay.run(this.id,'onclick');return false;" onkeydown="ebay.run(this.id,'onkeydown');return false;" title="Add pictures"
                  

                  如果在我的 webview 中按下此按钮,它会将新窗口从我的 webview 发送到 android 浏览器.但是如果在安卓浏览器中按下相同的按钮,它会弹出这个很酷的对话框类型的弹出窗口(见图)

                  If this button is pressed inside my webview, It sends the new window from my webview to the android browser. But if the same button is pressed from within the android browser it pops up this cool dialog type popup window (see picture)

                  如果在我的 web 视图中按下此按钮,我想像浏览器一样在 eBay 上打开弹出式窗口.以便用户在完成弹出窗口后将其关闭以将其返回到我的应用程序.

                  I would like to open the popup style window on eBay like the browser does, if this button is pressed inside my webview. So that it can be closed by the user to return them to my app behind it when they are done with the popup.

                  这可能吗?

                  这是我目前所拥有的:

                     webChromeClient = new WebChromeClient() {
                      @Override
                      public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg) {
                          WebView childView = new WebView(Ebay.this);
                          final WebSettings settings = childView.getSettings();
                          settings.setJavaScriptEnabled(true);
                          childView.setWebChromeClient(this);
                          childView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
                          WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
                          transport.setWebView(childView);
                          resultMsg.sendToTarget();
                  
                      return true;
                      }
                          @Override
                          public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
                              new AlertDialog.Builder(view.getContext()).setMessage(message).setCancelable(true).show();
                              result.confirm();
                              return true;
                  
                         }
                  

                  我错过了什么吗?

                  这是 android 浏览器弹出窗口的图片(我试图让我的 webview 从 ebay.com 上的按钮启动):

                  Here is a picture of the android browser popup (That I'm trying to get my webview to launch from the button on ebay.com):

                  推荐答案

                  你可以按照他的方式去做:

                  You can do it his way:

                  public void onCreate(Bundle savedInstanceState){
                    ....
                    webView.getSettings().setJavaScriptEnabled(true);
                    webView.addJavascriptInterface(new MyJSInterface(), "myappname");
                    webView.loadUrl("http://mysite.com/"); // or some local asset
                    ....
                  }
                  
                  public class MyJSInterface{
                  
                  ....
                   public void popup(){
                  
                  //  AlterDialog etc.
                  
                   }
                  ....
                  
                  }
                  
                  
                  HTML from your website:
                  
                  window.onload = function(){
                     window.myappname.popup();
                  }
                  

                  希望对你有用……

                  顺便说一句,小心 2.3 版本它有一个对应的 错误,仅供参考))

                  By the way, be careful with 2.3 version it had a corresponding bug, just FYI))

                  这篇关于可能的 WebView OnCreateWindow 制作弹出窗口(对话框样式)?像安卓浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:webview 不显示 javascript windows.open() 下一篇:在当前 web 视图中打开弹出/外部站点链接

                  相关文章

                1. <legend id='fQFGb'><style id='fQFGb'><dir id='fQFGb'><q id='fQFGb'></q></dir></style></legend>

                  <small id='fQFGb'></small><noframes id='fQFGb'>

                2. <i id='fQFGb'><tr id='fQFGb'><dt id='fQFGb'><q id='fQFGb'><span id='fQFGb'><b id='fQFGb'><form id='fQFGb'><ins id='fQFGb'></ins><ul id='fQFGb'></ul><sub id='fQFGb'></sub></form><legend id='fQFGb'></legend><bdo id='fQFGb'><pre id='fQFGb'><center id='fQFGb'></center></pre></bdo></b><th id='fQFGb'></th></span></q></dt></tr></i><div id='fQFGb'><tfoot id='fQFGb'></tfoot><dl id='fQFGb'><fieldset id='fQFGb'></fieldset></dl></div>

                    • <bdo id='fQFGb'></bdo><ul id='fQFGb'></ul>

                    <tfoot id='fQFGb'></tfoot>