How to disable phone number linking in Mobile Safari?

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

    A trick I use that works on more than just Mobile Safari is to use HTML escape codes and a little mark-up in the phone number. This makes it more difficult for the browser to "identify" a phone number, i.e.

    Phone: 1-8&#48;&#48;<span>-</span>62&#48;<span>-</span>38&#48;3
    
    0 讨论(0)
  • 2020-11-22 17:25

    Solution for Webview!

    For PhoneGap-iPhone / PhoneGap-iOS applications, you can disable telephone number detection by adding the following to your project’s application delegate:

    // ...
    
    - (void)webViewDidStartLoad:(UIWebView *)theWebView 
    {
        // disable telephone detection, basically <meta name="format-detection" content="telephone=no" />
        theWebView.dataDetectorTypes = UIDataDetectorTypeAll ^ UIDataDetectorTypePhoneNumber;
    
        return [ super webViewDidStartLoad:theWebView ];
    }
    
    // ...
    

    source: Disable Telephone Detection in PhoneGap-iOS.

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

    Break the number down into separate blocks of text

    301 <div style="display:inline-block">441</div> 3909
    
    0 讨论(0)
  • 2020-11-22 17:30

    My experience is the same as some others mentioned. The meta tag...

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

    ...works when the website is running in Mobile Safari (i.e., with chrome) but stops working when run as a webapp (i.e., is saved to home screen and runs without chrome).

    My less-than-ideal solution is to insert the values into input fields...

    <input type="text" readonly="readonly" style="border:none;" value="3105551212">
    

    It's less than ideal because, despite the border being set to none, iOS renders a multi-pixel gray bar above the field. But, it's better than seeing the number as a link.

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

    This seems to be the right thing to do, according to the Safari HTML Reference:

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

    If you disable this but still want telephone links, you can still use the "tel" URI scheme.

    Here is the relevant page at Apple's Developer Library.

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

    This answer trumps everything as of 6-13-2012:

    <a href="#" style="color: #666666; 
                       text-decoration: none;
                       pointer-events: none;">
      Boca Raton, FL 33487
    </a>
    

    Change the color to whatever matches your text, text decoration removes the underline, pointer events stops it from being viewed like a link in a browser (pointer doesn't change to a hand)

    This is perfect for HTML emails on ios and browser.

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