如何拥有的Android的WebView是目标“_blank” iframe中打开链接(How to

2019-08-17 14:26发布

解决了

只是把这个在OnCreate:奇怪只会“Android浏览器”中打开

        //webview settings
        myWebView = (WebView) findViewById(R.id.calwebview);
        myWebView.setBackgroundColor(Color.BLACK);
        myWebView.setWebViewClient(new MyWebViewClient());
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportMultipleWindows(true);
        myWebView.loadUrl("www.google.com");    
        myWebView.setWebChromeClient(new WebChromeClient() {
                @Override public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg)
                {
                    WebView newWebView = new WebView(view.getContext());
                    WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
                    transport.setWebView(newWebView);
                    resultMsg.sendToTarget();
                    return true;
                }
            });
文章来源: How to have Android webview open links that are target “_blank” within an iframe