Web开发中碰到到的问题

342 阅读1分钟
  1. iOS 中使用加载网页时有时会出现某个标签下面莫名奇妙的多出一个 <a> 标签的情况,标签属性一般会出现: x-apple-data-... 这样的内容,例如:
<a dir="ltr" herf="tel:2019-07-06%20/2019-07-07" x-apple-data-detectors="true" x-apple-data-detectors-result="0" x-apple-data-detectors-type="telephone">2019-07-06 /2019-07-07</a>

BUG图例

这是由于

iOS has an automatic feature to detect phone numbers and link them to a phone call by clicking on them.

可以通过添加

<meta name = "format-detection" content = "telephone=no">

解决;

也可以通过 AppleDevloper-documentation 上的提到的在 webView 上设置:

By default, a web view automatically converts telephone numbers that appear in web content to Phone links. When a Phone link is tapped, the Phone app launches and dials the number. To turn off this default behavior, set the dataDetectorTypes property with a UIDataDetectorTypes bitfield that does not contain the UIDataDetectorTypePhoneNumber flag.