iPhone上的Safari会自动为出现在电话号码中的数字字符串创建链接。我正在编写一个包含IP地址的网页,Safari将其转换为电话号码链接。是否可以为整个页面或页面上的某个元素禁用此行为?
当前回答
截至2012年6月13日,这个答案胜过一切:
<a href="#" style="color: #666666;
text-decoration: none;
pointer-events: none;">
Boca Raton, FL 33487
</a>
将颜色更改为与文本匹配的颜色,文本装饰删除下划线,指针事件阻止它像浏览器中的链接一样被查看(指针不会更改为手)
这是完美的HTML电子邮件在ios和浏览器。
其他回答
我也遇到了同样的问题,不过是在iPad网页应用上。
不幸的是,既不……
<meta name = "format-detection" content = "telephone=no">
也不……
0 = 0
9 = 9
... 工作。
但是,这里有三个丑陋的技巧:
用字母“O”代替数字“0” 用字母“l”代替数字“1” 插入一个没有意义的span:例如555.5<span>5</span>5.5555
取决于你使用的字体,前两个几乎不明显。后者显然包含多余的代码,但对用户是不可见的。
这当然是拙劣的技巧,如果您从数据动态生成代码,或者如果您不能以这种方式污染数据,那么这可能是不可行的。
但在紧要关头,这已经足够了。
要禁用特定元素的电话解析外观,下面的CSS似乎可以做到:
.element { pointer-events: none; }
.element > a { text-decoration:none; color:inherit; }
第一条规则禁止单击,第二条规则负责样式化。
根据Safari HTML参考,这似乎是正确的事情:
<meta name="format-detection" content="telephone=no">
如果您禁用了此功能,但仍然需要电话链接,则仍然可以使用“tel”URI方案。
这里是苹果开发者库的相关页面。
我自己测试过,发现它是有效的,尽管它肯定不是一个优雅的解决方案。在电话号码中插入空span将防止数据检测器将其转换为链接。
(604) 555<span></span> -4321
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.
推荐文章
- 保留HTML字体大小时,iPhone的方向从纵向改变为横向
- iPhone上UIView和UILabels的渐变
- keychain上的分发证书中缺少私钥
- 如何创建一个Swift Date对象?
- Xcode 4在目标设备上说“finished running <my app>”——什么都没有发生
- 从另一个应用程序打开设置应用程序
- 当我没有Mac的时候,在Mac/Safari上测试web应用程序
- Xcode 6 gitignore文件应该包括什么?
- 如何在iPhone/iOS上删除电话号码的蓝色样式?
- 检测视网膜显示
- 如何在UIImageView中动画图像的变化?
- 如何从iPhone访问SOAP服务
- 如何从iOS应用程序启动Safari和打开URL
- QuotaExceededError: Dom异常22:试图向存储添加一些超出配额的东西
- 在Objective-C中@property保留,赋值,复制,非原子