Use jQuery to detect whether a device can make telephone calls (supports “tel://” protocol)

前端 未结 4 2117
天命终不由人
天命终不由人 2020-11-28 14:37

In my website, I have several links like so:

218.111.2222

I want to use jQuery (or

4条回答
  •  没有蜡笔的小新
    2020-11-28 15:00

    One might be able to find the first instance of an href with tel:// in it and post an ajax call. If it was successful it should have a readyState of 1 so do nothing. On failure, find all hrefs with tel:// and grab inner html and replace the a tag.

    This is more of a hypothesis and untested.

    Another thought is most browser have custom support for phone number formatted strings, If you place in a phone number you shouldn't have to create the a tag as it should be done automatically.

提交回复
热议问题