-2

I am developing a mobile website and on a page there is text such as "AD 800-1200". If I press this text and release, iPhone asked me whether to dial a number.

How to prevent this?

Thanks!

curious1
  • 14,155
  • 37
  • 130
  • 231
  • I wonder if you could add an invisible character that confuses the algorithm that looks for phone numbers... – Floris Mar 05 '14 at 15:42
  • 2
    See [How to disable phone number linking in Mobile Safari?](http://stackoverflow.com/questions/226131/how-to-disable-phone-number-linking-in-mobile-safari). You need to disable the phone# searching, and then add links for any phone numbers using `tel:`. – Aaron Brager Mar 05 '14 at 15:42
  • 1
    @AaronBrager - thanks for that link. I had already written a different answer but I have included the `` trick from that answer for completeness. – Floris Mar 05 '14 at 15:57

2 Answers2

3

See the following html:

<html>
<div id="s2">AD 800&#8232-1200</div>
<div id="s2">AD 800-1200</div>
<div id="s2">AD 800 - 1200</div>
<div id="phone">(800)123-4567</div>
</html>

The first and third line produce "no phone number", while the second and fourth do. You can see for yourself at http://www.floris.us/SO/phoneme.html

Note - the "magic number" in the first example is a unicode control character that does not render to the screen - but it does throw the "number parser". With this trick you can have a number that "looks" exactly like a phone number, but doesn't get recognized as such.

The third example just adds spaces around the hyphen - that seems to work too.

I can't claim all the credit for this cleverness. I did see https://stackoverflow.com/a/17507409/1967396 ...

One other thing: you can add the following line to the header of your file:

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

This will turn off telephone number detection. This latter trick can be found at https://stackoverflow.com/a/227238/1967396 - with thanks to Aaron Brager for bringing it to my attention.

Community
  • 1
  • 1
Floris
  • 45,857
  • 6
  • 70
  • 122
2

If you are using a webview uncheck the property "Phone Numbers detection" in your XIB

enter image description here

Fran Martin
  • 2,369
  • 22
  • 19