我无法在Android上覆盖WebViewClient函数shouldInterceptRequest。没有错误,但没有调用该函数。我错过了什么?
函数shouldInterceptRequest()的文档; http://developer.android.com/reference/android/webkit/WebViewClient.html
if(application.android){
try{
android.webkit.WebViewClient.extend({
shouldInterceptRequest: function(_webView,webResourceRequest){
alert('shouldInterceptRequest is called');
return null;
}
});
}catch(e){
alert(e.message);
}
}
答案 0 :(得分:0)
我没有看到您将WebViewClient
设置为WebView
。尝试做类似的事情:
var myWebView = page.getViewById("myWebView");
if (myWebView.android) {
try {
var MyWebViewClient = android.webkit.WebViewClient.extend({
shouldInterceptRequest: function(_webView,webResourceRequest){
alert('shouldInterceptRequest is called');
return null;
}
});
myWebView.android.setWebViewClient(new MyWebViewClient());
} catch(e) {
alert(e.message);
}
}