【问题标题】:How to open a window(poup) on mobile browser from inside a webview using javascript?如何使用javascript从webview内部打开移动浏览器上的窗口(弹出窗口)?
【发布时间】:2017-10-10 10:44:09
【问题描述】:

我有一个网页,如果在 webview 中加载该网页,则该页面应在移动 web 浏览器中重新加载,而不是在 webview 中。 基本上我想将用户从 webview 发送到浏览器。 这可以使用 javascript 或 jquery 吗?

【问题讨论】:

    标签: javascript jquery html webview


    【解决方案1】:

    这是 webview 中对话框或弹出窗口的示例:

    AlertDialog.Builder alert = new AlertDialog.Builder(this); 
    alert.setTitle("Title here");
    
    WebView wv = new WebView(this);
    wv.loadUrl("http:\\www.google.com");
    wv.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
    
            return true;
        }
    });
    
    alert.setView(wv);
    alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });
    alert.show();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      相关资源
      最近更新 更多