如何让Android webview在iframe中打开目标为“_blank”的链接

时间:2013-03-13 23:00:09

标签: android iframe webview target

解决

把它放在oncreate中:奇怪的是只会在“android browser”中打开

        //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;
                }
            });

0 个答案:

没有答案