在測(cè)試中發(fā)現(xiàn)iPad上的Safari總會(huì)把長(zhǎng)串?dāng)?shù)字識(shí)別為電話號(hào)碼,文字變成藍(lán)色匣吊,點(diǎn)擊還會(huì)彈出菜單添加到通訊錄盒件。
別的地方倒也罷了,如果在用戶名中出現(xiàn)數(shù)字(手機(jī)注冊(cè)新浪微博的話用戶名就是“手機(jī)用戶xxxxxxxx”)昂灵,版式會(huì)很惡心避凝。
經(jīng)過(guò)測(cè)試在a標(biāo)簽中的長(zhǎng)串?dāng)?shù)字不會(huì)識(shí)別為電話,于是給出現(xiàn)用戶名但沒(méi)有鏈接的地方嵌套一個(gè)無(wú)動(dòng)作的a標(biāo)簽眨补,臨時(shí)解決了這個(gè)問(wèn)題管削。
但是這樣增加了額外的標(biāo)簽,代碼的語(yǔ)義性變得很差撑螺,而且對(duì)大段文字不能用這個(gè)方法含思。
今天無(wú)意中撞進(jìn)Safari的官網(wǎng),發(fā)現(xiàn)了safari有個(gè)私有meta屬性可以解決這個(gè)問(wèn)題:
{ meta name="format-detection" content="telephone=no" / }
官網(wǎng)的說(shuō)明如下: 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.