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

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

    Some limited solution can be a way to detect some pure phones. But not all possible:

    (function(a) {
    	window.isPhone = /\bi?Phone\b|(?=.*\bAndroid\b)(?=.*\bMobile\b)|(?=.*\bAndroid\b)(?=.*\bSD4930UR\b)/i.test(a);
    })(navigator.userAgent || navigator.vendor || window.opera);
    
    console.info('This device %s make phone calls', window.isPhone ? 'is originally intended to' : 'probably can\'t' );

提交回复
热议问题