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


当前回答

Sencha Touch的index.html中的meta标签(<meta name="format-detection" content="telephone=no">)解决了同样的问题。

其他回答

我自己测试过,发现它是有效的,尽管它肯定不是一个优雅的解决方案。在电话号码中插入空span将防止数据检测器将其转换为链接。

(604) 555<span></span> -4321

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中的电话检测。

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

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

Sencha Touch的index.html中的meta标签(<meta name="format-detection" content="telephone=no">)解决了同样的问题。

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

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