一个work around方法:解决Android 3.0~4.0上WebView 对锚点链接不支持的bug
"The webpage at file:///android_asset/other_file.html#fragmentmight...."?在 ?http://code.google.com/p/android/issues/detail?id=17327?里有很热闹的讨论。
?
mWebView.setWebViewClient(new WebViewClient() {
?
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d("erik", "loadUrl ,url = " + url);
view.loadUrl(url);
return true;
}
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
if(failingUrl.contains("#")){
Log.d("erik", "failingurl = " + failingUrl);
String[] temp;
temp = failingUrl.split("#");
view.loadUrl(temp[0]); // load page without internal
try {
Thread.sleep(400);
} catch (InterruptedException e) {
?
e.printStackTrace();
}
view.goBack();
view.goBack();
}
}
});