[英]Android WebView html href value format
I have a webview in my Fragment. 我的片段中有一个webview。 An HTML string is loaded to it.
将加载HTML字符串。 The string contains the link tag:
"<a href="anyText">anyText</a>"
Then I set a webviewclient for my webview. 该字符串包含链接标记:
"<a href="anyText">anyText</a>"
然后我为webview设置了webviewclient。
webview.setWebViewClient(new WebViewClient() {
// you tell the webclient you want to catch when a url is about to load
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
Logger.d("url="+url);
return true;
}
// here you execute an action when the URL you want is about to load
@Override
public void onLoadResource(WebView view, String url){
Logger.d("url="+url);
}
});
My issue is that if click on the link, my WebViewClient cannot catch it. 我的问题是,如果单击链接,我的WebViewClient无法捕获它。 But if I change it to
"<a href="http://google.com">anyText</a>"
, then it will work cos the href value is a valid link. 但是,如果我将其更改为
"<a href="http://google.com">anyText</a>"
,那么它将起作用,因为href值是一个有效的链接。 What I wanted to achieve to is put any href value and catch it. 我想要实现的是放入任何href值并抓住它。 I am also NOT visiting any site here.
我也没有访问这里的任何网站。 Just want to catch that anyText and do something else.
只想抓住任何文本并做其他事情。
String url =“https://www.google.com”您是否在Android清单中提供了网络权限?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.