How to disable phone number linking in Mobile Safari?

前端 未结 24 1419
面向向阳花
面向向阳花 2020-11-22 16:56

Safari on iPhone automatically creates links for strings of digits that appear to the telephone numbers. I am writing a web page containing an IP address, and Safari is tur

相关标签:
24条回答
  • 2020-11-22 17:16

    Why would you want to remove the linking, it makes it very user friendly to have th eoption.

    If you simply want to remove the auto editing, but keep the link working just add this into your CSS...

    a[href^=tel] {
     color: inherit;
     text-decoration:inherit;
    }
    
    0 讨论(0)
  • 2020-11-22 17:18

    You can also use the <a> label with javascript: void(0) as href value.

    Example as follow:
    <a href="javascript: void(0)">+44 456 77 89 87</a>

    0 讨论(0)
  • 2020-11-22 17:19

    I too have this problem: Safari and other mobile browsers transform the VAT IDs into phone numbers. So I want a clean method to avoid it on a single element, not the whole page (or site).
    I'm sharing a possible solution I found, it is suboptimal but still it is pretty viable: I put, inside the number I don't want to become a tel: link, the &#8288; HTML entity which is the Word-Joiner invisible character. I tried to stay more semantic (well, at least a sort of) by putting this char in some meaning spot, e.g. for the VAT ID I chose to put it between the different groups of digit according to its format so for an Italian VAT I wrote: 0613605&#8288;048&#8288;8 which renders in 0613605⁠048⁠8 and it is not transformed in a telephone number.

    0 讨论(0)
  • 2020-11-22 17:20

    I use a zero-width joiner &zwj;

    Just put that somewhere in the phone number and it works for me. Tested in BrowserStack (and Litmus for emails).

    0 讨论(0)
  • 2020-11-22 17:22

    To disable the phone parsing appearance for specific elements, this CSS seems to do the trick:

    .element { pointer-events: none; }
    .element > a { text-decoration:none; color:inherit; }
    

    The first rule disables the click, the second takes care of the styling.

    0 讨论(0)
  • 2020-11-22 17:22

    Another option is to replace the hyphens in your phone number by the character (U+2011 'Unicode Non-Breaking Hyphen')

    0 讨论(0)
提交回复
热议问题