Open Yhzhtk opened 11 years ago
WebViewClient主要帮助WebView处理各种通知、请求事件的,比如:
onLoadResource onPageStart onPageFinish onReceiveError onReceivedHttpAuthRequest
WebChromeClient主要辅助WebView处理Javascript的对话框、网站图标、网站title、加载进度等比如:
onCloseWindow(关闭WebView) onCreateWindow() onJsAlert (WebView上alert无效,需要定制WebChromeClient处理弹出) onJsPrompt onJsConfirm onProgressChanged onReceivedIcon onReceivedTitle
看上去他们有很多不同,实际使用的话,如果你的WebView只是用来处理一些html的页面内容,只用WebViewClient就行了,如果需要更丰富的处理效果,比如JS、进度条等,就要用到WebChromeClient。
shouldInterceptRequest 只是在API 11 过后才加上,如果要在API 11以前进行类容替换,应该如何处理?