问题
I have a UIWebview that I am loading with custom HTML using loadHtmlString. My HTML has a link that I intercept when tapped so that I can take control and reload the UIWebview with a different HTML string. The code works, but the area where the link text was located is replaced with a gray rectangle that is visible when the new string is loaded.
What could be going on here? How can I get rid of this behavior?
//Scott
回答1:
Here it is...need to add this style statement to the link reference:
<a href=http://yourlink.com/ style = "-webkit-tap-highlight-color:rgba(0,0,0,0);">
Setting the alpha value (the last parameter to rgba) to 0 disables the tap highlight color.
Although this works, it feels like a hack. I really think the tap highlight should clear itself when my second loadHtmlString reloads new HTML code.
//Scott
回答2:
You could add onclick="this.blur(); location.href=this.href;" to the link to remove the focus from the link.
I'm sure there's a better less hackish way, but this should work
来源:https://stackoverflow.com/questions/1371036/why-would-a-link-in-a-uiwebview-leave-a-gray-box-behind