iPhone上的Safari会自动为出现在电话号码中的数字字符串创建链接。我正在编写一个包含IP地址的网页,Safari将其转换为电话号码链接。是否可以为整个页面或页面上的某个元素禁用此行为?
当前回答
我也遇到了同样的问题,不过是在iPad网页应用上。
不幸的是,既不……
<meta name = "format-detection" content = "telephone=no">
也不……
0 = 0
9 = 9
... 工作。
但是,这里有三个丑陋的技巧:
用字母“O”代替数字“0” 用字母“l”代替数字“1” 插入一个没有意义的span:例如555.5<span>5</span>5.5555
取决于你使用的字体,前两个几乎不明显。后者显然包含多余的代码,但对用户是不可见的。
这当然是拙劣的技巧,如果您从数据动态生成代码,或者如果您不能以这种方式污染数据,那么这可能是不可行的。
但在紧要关头,这已经足够了。
其他回答
我有一个ABN(澳大利亚商业号码),iPad Safari坚持要把它变成一个电话号码链接。这些建议都没用。我的解决方案是在数字之间加上img标签。
ABN 98<img class="PreventSafariFromTurningIntoLink" /> 009<img /> 675<img /> 709
该类的存在只是为了记录img标记的用途。
适用于iPad 1(4.3.1)和iPad 2(4.3.3)。
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中的电话检测。
要禁用特定元素的电话解析外观,下面的CSS似乎可以做到:
.element { pointer-events: none; }
.element > a { text-decoration:none; color:inherit; }
第一条规则禁止单击,第二条规则负责样式化。
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 ⁠ 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⁠048⁠8 which renders in 06136050488 and it is not transformed in a telephone number.
另一种选择是将你电话号码中的连字符替换为字符- (U+2011“Unicode非断续连字符”)
推荐文章
- 我如何改变UIButton标题颜色?
- Xcode 4挂在“附加到(应用程序名称)”
- 缺少推荐的图标文件-该包不包含iPhone / iPod Touch的应用程序图标,像素为“120x120”,png格式
- 如何使用Xcode创建。ipa文件?
- Xcode 4 -在新的Macintosh安装上的配置文件上“没有找到有效的签名标识”错误
- 在iPhone上确定用户是否启用了推送通知
- 是否有可能禁用浮动头在UITableView与UITableViewStylePlain?
- Swift -转换为绝对值
- 在代码中为UIButton设置一个图像
- 如何修复UITableView分隔符在iOS 7?
- 在Swift中根据字符串计算UILabel的大小
- 如何调用手势点击在UIView编程在迅速
- 我如何隐藏在一个Swift iOS应用程序的状态栏?
- 对于实例消息,接收方类型***是转发声明
- 如果模态ViewController演示样式为UIModalPresentationFormSheet, iPad键盘将不会解散