iPhone上的Safari会自动为出现在电话号码中的数字字符串创建链接。我正在编写一个包含IP地址的网页,Safari将其转换为电话号码链接。是否可以为整个页面或页面上的某个元素禁用此行为?
当前回答
要禁用特定元素的电话解析外观,下面的CSS似乎可以做到:
.element { pointer-events: none; }
.element > a { text-decoration:none; color:inherit; }
第一条规则禁止单击,第二条规则负责样式化。
其他回答
<meta name = "format-detection" content = "telephone=no">对电子邮件不起作用:如果你正在准备的HTML是电子邮件,元标签将被忽略。
如果你的目标是电子邮件,这里还有一个丑陋但有效的解决方案:
一些你想避免链接或自动格式化的HTML的例子:
will cease operations <span class='ios-avoid-format'>on June 1,
2012</span><span></span>.
和CSS,将使魔术发生:
@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";}
}
缺点:你可能需要对ipad/iphone的每一个纵向/横向组合进行媒体查询
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.
Sencha Touch的index.html中的meta标签(<meta name="format-detection" content="telephone=no">)解决了同样的问题。
我自己测试过,发现它是有效的,尽管它肯定不是一个优雅的解决方案。在电话号码中插入空span将防止数据检测器将其转换为链接。
(604) 555<span></span> -4321
添加元标记来关闭格式检测对我来说不起作用。我试图在<p>标签和其他文本中显示缩放会议ID, iOS将该ID转换为电话链接。此外,我通过一个[href^="tel:"]定位电话链接,以便给他们自定义样式,因此禁用电话链接上的样式不是一个选项。
我找到的解决方案是将ID号包装在<code>标记中。这似乎可以防止iOS干扰它。
推荐文章
- 我如何改变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键盘将不会解散