虽然在SO(我可能读过其中大部分)中讨论了shouldOverrideUrlLoading()方面的问题,但我仍然没有找到解决方案,看起来像我这样一个通用的问题,我相信已经解决了。shouldOverrideUrlLoading()没有从iframe调用外部链接
问题:如何在forOverrideUrlLoading()中停止外部链接,例如“http://www.example.com”,用于加载webView.loadDataWithBaseURL()的页面,其中baseUrl是“file:/// ...”?
当外部链接被触摸(点击)时,我不会调用shouldOverrideUrlLoading()的override方法。 Here它说:“无法用基本URL解析的URL被放置在地板上(你不会为它们获得任何回调,也不应该在OverrideUrlLoading和onPageStarted)。” Android开发人员网站说here“如果您通过调用... loadDataWithBaseURL()加载页面,则将在页面上收到此类型链接的shouldOverrideUrlLoading()回调。” 这是我的代码:
public void loadEpub(final EpubInfo epubInfo)
{
post(new Runnable()
{
@Override
public void run()
{
epubBaseUrl = "file://" + epubInfo.path;
if (!epubBaseUrl.endsWith("/"))
epubBaseUrl += "/";
String path = epubBaseUrl + epubInfo.baseUrl;
String page = generatePage(epubInfo);
EpubWebView.super.loadDataWithBaseURL(path, page, "text/html", "UTF-8", null);
}
});
}
哪里我的baseUrl(路径) “文件:///存储/ sdcard0 /安卓/数据/ ...”。
非常感谢提前。