Disabling visible links in UIWebView

前端 未结 3 1652
醉酒成梦
醉酒成梦 2021-01-22 21:31

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

I disallow links in the delegate method shouldStartLoadWithRequ

相关标签:
3条回答
  • 2021-01-22 22:07

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

    Removing the href from all anchors should clear the formatting.

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

    for(a in document.getElementsByTagName("a")) { a.href= ""; }
    
    0 讨论(0)
  • 2021-01-22 22:19

    This will do it:

    self.webView.dataDetectorTypes = UIDataDetectorTypeNone;
    
    0 讨论(0)
  • 2021-01-22 22:24

    For swift 3:

    Try removing the types you don't want to show as link from webView.dataDetectorTypes

    webView.dataDetectorTypes.remove(UIDataDetectorTypes.all)
    
    0 讨论(0)
提交回复
热议问题