bhu*_*ups 5 javascript android android-webview
有没有办法拦截javascript触发的URL在WebView正常的hrefs使用shouldOverrideUrlLoading()?
onLoadResource()在调用任何资源时调用,包括JavaScript.目的有点不同shouldOverrideUrlLoading().
webControls.setWebViewClient(new WebViewClient() {
//Notify the host application that the WebView will load
//the resource specified by the given url.
@Override
public void onLoadResource (WebView view, String url) {
super.onLoadResource(view, url);
Log.v(TAG, "onLoadResource("+url+");");
}
//Give the host application a chance to take over the
//control when a new url is about to be loaded in the
//current WebView.
@Override
public void shouldOverrideUrlLoading(WebView view, String url) {
super.shouldOverrideUrlLoading(view, url);
Log.v(TAG, "shouldOverrideUrlLoading("+url+");");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2920 次 |
| 最近记录: |