wap頁面中手機號碼處理總結

1、防止在iOS設備中的Safari將數字識別爲電話號碼

在測試中發現iPad上的Safari總會把長串數字識別爲電話號碼,文字變成藍色,點擊還會彈出菜單添加到通訊錄。

別的地方倒也罷了,如果在用戶名中出現數字(手機註冊新浪微博的話用戶名就是“手機用戶xxxxxxxx”),版式會很噁心。

經過測試在a標籤中的長串數字不會識別爲電話,於是給出現用戶名但沒有鏈接的地方嵌套一個無動作的a標籤,臨時解決了這個問題。

但是這樣增加了額外的標籤,代碼的語義性變得很差,而且對大段文字不能用這個方法。

今天無意中撞進Safari的官網,發現了safari有個私有meta屬性可以解決這個問題:

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

官網的說明如下: 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.


2、點擊撥打

<a href="tel:電話號碼">電話號碼</a>


3、自定義被識別的手機號碼

被識別後也就是自動加了超鏈接,通過子級選擇器定義a標籤即可


<div class="content">手機:1300000000</div>

.content a{color:#000;}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章