How to disable phone number linking in Mobile Safari?

前端 未结 24 1420
面向向阳花
面向向阳花 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:33

    I was really confused by this for a while but finally figured it out. We made updates to our site and had some numbers converting to a link and some weren't. Turns out that numbers won't be converted to a link if they're in a <fieldset>. Obviously not the right solution for most circumstances, but in some it will be the right one.

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

    <meta name = "format-detection" content = "telephone=no"> does not work for emails: if the HTML you are preparing is for an email, the metatag will be ignored.

    If what you are targeting are emails, here's yet another ugly-but-works solution for ya'll:

    Example of some HTML you want to avoid being linked or auto formatted:

    will cease operations <span class='ios-avoid-format'>on June 1,
    2012</span><span></span>.
    

    And the CSS that will make the magic happen:

    @media only screen and (device-width: 768px) and (orientation:portrait){
    span.ios-date{display:none;}
    span.ios-date + span:after{content:"on June 1, 2012";}
    }
    

    The drawback: you may need a media query for each of the ipad/iphone portrait/landscape combos

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

    Think I've found a solution: put the number inside a <label> element. Haven't tried any other tags, but <div> left it active on the home screen, even with the telephone=no attribute.

    It seems obvious from earlier comments that the meta tag did work, but for some reason has broken under the later versions of iOS, at least under some conditions. I am running 4.0.1.

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

    To disable phone number detection on part of a page, wrap the affected text in an anchor tag with href="#". If you do this, mobile Safari and UIWebView should leave it alone.

    <a href="#"> 1234567 </a>
    
    0 讨论(0)
  • 2020-11-22 17:37

    I had an ABN (Australian Business Number) that iPad Safari insisted on turning into a phone number link. None of the suggestions helped. My solution was to put img tags between the numbers.

    ABN 98<img class="PreventSafariFromTurningIntoLink" /> 009<img /> 675<img /> 709
    

    The class exists only to document what the img tags are for.

    Works on iPad 1 (4.3.1) and iPad 2 (4.3.3).

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

    Same problem in Sencha Touch app solved with meta tag (<meta name="format-detection" content="telephone=no">) in index.html of app.

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