在UIWebView中禁用可见链接 [英] Disabling visible links in UIWebView

查看:105
本文介绍了在UIWebView中禁用可见链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式中有许多网页检视,我需要注意允许其他HTML连结。

I have a number of web views in my app in which I need to be careful about allowing further HTML links.

我不允许委托方法shouldStartLoadWithRequest中的链接。这工作正常,除了一件事。在Web视图中,链接仍以蓝色突出显示。所以用户自然认为他们是活动链接,但是当选择时,我不允许从委托方法的链接。这导致用户的混乱。

I disallow links in the delegate method shouldStartLoadWithRequest. This works fine, except for one thing. In the web view, the links are still highlighted in blue. So the user naturally thinks they are active links, but when selected, I disallow the link from the delegate method. This leads to confusion for the user.

有没有方法可以禁用链接颜色,因此当文本包含UIWebView中的链接时,文本不会显示为蓝色?

Is there a way for me to disable the link color, so text does not show as blue when it contains a link within a UIWebView?

推荐答案

尝试将Javascript 注入UIWebView以更改链接的外观。

Try injecting Javascript into the UIWebView to change the appearance of the links.

从所有锚中删除 href 应清除格式化。

Removing the href from all anchors should clear the formatting.

这里有一些Javascript让你开始,如果你需要它:

Here's some Javascript to get you started if you need it:

for(a in document.getElementsByTagName("a")) { a.href= ""; }

这篇关于在UIWebView中禁用可见链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆