我的应用程序使用Webview加载网站。有些链接的目标是_blank并在新窗口中打开
public class EkChromeViewClient extends android.webkit.WebChromeClient {
@Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
Log.d("!!!new window!!!", "yes");
WebView newWebView = new WebView(view.getContext());
newWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
newWebView.getSettings().setDomStorageEnabled(true);
newWebView.getSettings().setSupportMultipleWindows(true);
newWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
newWebView.setWebViewClient(new EkWebViewClient());
view.addView(newWebView);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(newWebView);
resultMsg.sendToTarget();
return true;
}
@Override
public void onCloseWindow(WebView window) {
Log.d("!!!close window!!!", "yes");
super.onCloseWindow(window);
}
}
但是我只需要在一个窗口中打开所有网址,而忽略target = _blank
答案 0 :(得分:0)
您需要执行以下操作。
ViewController