Shellway的博客

iOS中的Safari将数字识别为电话号码的解决方法

最近在项目开发中发现,iPhone上的Safari(App内置的UIWebview也一样)总会把HTML中所有长串数字都识别为电话号码,文字变成蓝色,点击还会弹出菜单添加到通讯录。

而后我请出了度娘,无意中撞进Safari的官网,发现了safari有个私有meta属性可以解决这个问题:


上面标签标示不启用手机号码格式检测,页面中出现的连续数字串就不会自动解析为电话号码链接了。

当然,如果要开启格式检测,把content的值设置成“telephone=yes”就可以了。

官网的说明如下: How do I disable automatic detection of phone numbers in webpages? In Safari on iPhone, phone numbers are automatically detected and transformed into links that dial the phone number when tapped. If you have strings of numbers in your webpage that should not be automatically detected as phone numbers, you can choose to disable this feature on the entire page by adding the meta tag shown in Listing 12.


好好学习,天天向上