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

前端 未结 4 2118
天命终不由人
天命终不由人 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 14:45

    I'm not sure about Android or BlackBerry, but iOS will automatically pick up telephone numbers and wrap them like so: xxx...so you could have a hidden

    somewhere that contains a phone number like 1-800-555-5555, then, on page load do something like this:

    var isTelephone = $("a[href*='tel:']").length > 0;
    

    This may or may not be portable to other platforms, you'll have to try it out.

提交回复
热议问题