Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling data detectors for a specific HTML element in a UIWebView

Does anyone know if it's possible to disable the data detectors for phone numbers, email addresses etc in a UIWebView, for specific HTML elements only?

I'd like the detectors to be active for most of the content loaded into the UIWebView, but disable it in certain areas.

If this is possible, I'm assuming it would be achieved by using an HTML attribute in the loaded content (rather than setting some sort of UIWebView property), e.g.

<html>
  <body>
    <h1 datadetectors="off">Header text with number 9123 3456</h1>
    <p>Body text with number 9872 4567</p>
  </body>
</html>

In this example, the number in the <p> would be detected as a phone number due to setting webview.dataDetectorTypes = UIDataDetectorTypeAll, whereas the number in the <h1> would not.

like image 689
Mark Beaton Avatar asked Jan 21 '10 00:01

Mark Beaton


2 Answers

you should use <meta name = "format-detection" content = "telephone=no">

Hope it helps

like image 183
Braian Mellor Avatar answered Sep 28 '22 09:09

Braian Mellor


you can put the attribute

x-apple-data-detectors="false"

but unfortunately this seems to work only for tags. I ended up using this solution:

<a href="#" x-apple-data-detectors="false">666-777-777</a>

besides disabling the telephone numbers "detection", this also prevents adresses and other detection to run.

like image 28
parasew Avatar answered Sep 28 '22 10:09

parasew