Javascript:检测设备是否可以拨打电话 [英] Javascript: Detect if device can make phonecall

查看:109
本文介绍了Javascript:检测设备是否可以拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检测设备是否可以拨打电话?我有一个包含电话号码列表的网页。如果设备可以使用 tel:链接进行呼叫,我想让它们可点击。当我点击桌面浏览器中的这样一个链接时,Firefox报告:

Is it possible to detect if a device can make a phonecall or not? I have a webpage with a list of phone numbers. I want to make them clickable if the device can call, using the tel: link. When I click on such a link in my desktop browser, Firefox reports:


地址未被理解

Firefox不知道如何打开此地址,因为以下协议之一(tel)与任何程序无关或在此上下文中不允许。

Firefox doesn't know how to open this address, because one of the following protocols (tel) isn't associated with any program or is not allowed in this context.

我知道移动设备检测。这不是我想要的,因为大多数平板电脑都是移动设备,但无法拨打电话。

I know about mobile device detection. This does not what I want, because most tablets are mobile but can't make a phone call.

问题


  • 是否可以检测到如果设备可以使用Javascript或HTML拨打电话,如果是这样的话?

  • 如果无法做到这一点,最好的办法是什么?

推荐答案

我认为iOS会自动执行此操作,不确定其他操作系统。但是,如果您只是使用简单的Javascript / jQuery按名称检查设备,那还不够吗?

I think iOS does this automatically, not sure about the other OS. But if you just check the devices by their name using simple Javascript/jQuery, wouldn't that be sufficient?

这样的事情:

$.browser.device = (/android|webos|iphone|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));

这篇关于Javascript:检测设备是否可以拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆