Why would a link in a UIWebView leave a gray box behind?

风格不统一 提交于 2019-12-07 19:26:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!