Incorrect iOS Webkit Phone Number Detection

By June 22, 2011Blog

Here is an interesting tidbit for those of you developing cross-platform for the mobile browsing market. Specifically webkit on the iPad and the iPhone.

I just ran into a situation this morning where one of the developers I work with had a site that was turning a random string of numbers on a page into a phone number and the iPad would automatically convert it to a link that would ask you to add it to your contacts. The problem is that, the number in question was not a phone number. So I fired up my search engine and found that this is a common problem.

One developer has a site that returns the results of ip address in a network, and another that gives mathematical results of geo location height and widths over miles of land rounded down with sometimes over 5 decimal places. The iPad and iPhone just go ahead and assume that they are phone numbers and screw the touch features up on your website.

Go ahead and search the population of america on your i-device.. 311,606,889 – and out of about 10 different pages, about 5 of them thought it was a phone number for me. So here is the fix and it works in iOS 3.2.2 or higher.(4.3.1 as of this writing)

Turn off telephone number detection.
<meta name = “format-detection” content = “telephone=no”>

Here is the link to the apple developer page where I found the code:

I hope this helps some frustrated developer out there…

Also, if you’re developing an iPhone or iPad app, you can disable in-app by adding the following to your reference code base:

– (void)webViewDidStartLoad:(UIWebView *)theWebView
// disable telephone detection, basically
theWebView.dataDetectorTypes = UIDataDetectorTypeAll ^ UIDataDetectorTypePhoneNumber;

return [ super webViewDidStartLoad:theWebView ];