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


当前回答

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

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

其他回答

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

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

要在页面的某些部分禁用电话号码检测,请使用href="#"将受影响的文本包装在锚定标记中。如果你这样做,移动Safari和UIWebView应该不去管它。

<a href="#"> 1234567 </a>

你也可以使用<a>标签和javascript: void(0)作为href值。示例如下:<a href="javascript: void(0)">+44 456 77 89 87</a>

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 &#8288; 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&#8288;048&#8288;8 which renders in 0613605⁠048⁠8 and it is not transformed in a telephone number.

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

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