Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you disable phone number detection in mobile safari

I have tried to disable phone number detection in safari for my web app but it still shows 7 character strings comprised of numbers as phone numbers. I used the apple provided meta tag but no joy.

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

Anyone else run into this problem and work around it?

Thanks.

Update: It looks like it does not detect phone numbers in safari but rather when I save the page as an icon and run it from the home screen.

like image 922
yodaisgreen Avatar asked Sep 06 '10 07:09

yodaisgreen


3 Answers

OK. After quite a bit of futzing I think I found a strange work around. The problem with using dataDetectorTypes is that it will disable phone number detection for the whole uiwebveiw.

After trying datadetectors="off" and x-apple-data-detectors="false" attribute on span and a tags I finally stumbled on something that seems to prevent phone number detection.

If I wrap my text in an a tag with an href="#" apple seems to leave it alone.

like image 195
yodaisgreen Avatar answered Sep 24 '22 09:09

yodaisgreen


Are you loading this in a UIWebView? If so, you need to set the property for dataDetectorTypes. e.g:

webView.dataDetectorTypes = UIDataDetectorTypeNone

Valid detector types are here.

Search for UIWebView on apple's site for a description of how to set the property there.

-Kevin

like image 39
Kevin Franklin Avatar answered Sep 26 '22 09:09

Kevin Franklin


We had a similar problem on our JQM/Cordova app. We had a calculator built into the app and whenever the amount was more than seven digits the data would be in blue with an underline underneath and when you click on the data a pop up appeared and gave you the option to call. We simply added the meta tag as described in the opening question & it worked.

Just adding some thought here in case anybody else has a similar issue with Safari detecting 7 stringed data as telephone numbers.

like image 34
Boyds Avatar answered Sep 26 '22 09:09

Boyds