iPhone上的Safari会自动为出现在电话号码中的数字字符串创建链接。我正在编写一个包含IP地址的网页,Safari将其转换为电话号码链接。是否可以为整个页面或页面上的某个元素禁用此行为?


当前回答

将数字分解成不同的文本块

301 <div style="display:inline-block">441</div> 3909

其他回答

截至2012年6月13日,这个答案胜过一切:

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

将颜色更改为与文本匹配的颜色,文本装饰删除下划线,指针事件阻止它像浏览器中的链接一样被查看(指针不会更改为手)

这是完美的HTML电子邮件在ios和浏览器。

你可以尝试将它们编码为HTML实体:

&#48; = 0
&#57; = 9

我使用零宽度细木工&zwj;

把这句话放在电话号码里就行了。在BrowserStack(和Litmus用于电子邮件)中测试。

加上这个,我想这就是你想要的:

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

Webview解决方案!

对于PhoneGap-iPhone / PhoneGap-iOS应用程序,您可以通过在项目的应用程序委托中添加以下内容来禁用电话号码检测:

// ...

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

    return [ super webViewDidStartLoad:theWebView ];
}

// ...

来源:禁用PhoneGap-iOS中的电话检测。