先讲述一下
webView.loadDataWithBaseURL(url, doc, mimeType, charset, url);
函数原型
void android.webkit.WebView.loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl)Parameters: baseUrl Url to resolve relative paths with, if null defaults to "about:blank" data A String of data in the given encoding. mimeType The MIMEType of the data. i.e. text/html. If null, defaults to "text/html" encoding The encoding of the data. i.e. utf-8, us-ascii historyUrl URL to use as the history entry. Can be null.说一下方法遇到的几个问题
1: 如果不写 baseUrl 指定data内的 超链接如果写的是 /开头的uri 的话, 将会无法访问
2:baseUrl 如果写成主机的domain 例如 http://www.google.cn可以访问 data中的超链接,但是 无法使用 goback
3: 将 baseUrl 与 historyUrl 写成相同的,一切正常