检测 HTML <a>Javascript 中的点击通话支持 [英] Detecting HTML <a> click-to-call support in Javascript

查看:20
本文介绍了检测 HTML <a>Javascript 中的点击通话支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 HTML 中有两种方法可以使用点击通话链接

There are two ways to have click-to-call links in HTML

  • <a href="wtai://wp/mc;+1800229933</a> WTAI 风格(诺基亚,其他)

  • <a href="wtai://wp/mc;+1800229933</a> WTAI style (Nokia, others)

拨打 Apple 客户支持电话 1-800-275-2273. 电话风格(苹果)

<a href="tel:+1-800-275-2273">Call Apple Customer Support at 1-800-275-2273</a>. TEL style (Apple)

怎样才能

  • 在Javascript中检测当前用户代理支持哪种格式?

  • detect which format is supported by current user agent in Javascript?

是否可以不依赖用户代理字符串进行检测

Is it possible to do the detection without relying the user agent string

更多信息

http://www.raizlabs.com/blog/2007/07/02/iphone-telephone-hyperlinks/

推荐答案

Max Firtman 有一篇关于 如何为移动浏览器创建点击通话链接.他表示,几乎所有移动设备都支持 tel: 协议,包括:iOS 上的 Safari、Android 浏览器、webOS 浏览器、Symbian 浏览器、Internet Explorer、Opera Mini 和低端设备浏览器.

Max Firtman has a great article on how to create click-to-call links for mobile browsers. He states that the tel: protocol is supported by almost every mobile device, including: Safari on iOS, Android Browser, webOS Browser, Symbian browser, Internet Explorer, Opera Mini and low-end devices browsers.

由于 tel: 协议的广泛支持,我建议只使用 tel: 协议.为了支持诺基亚,我会检查 navigator.userAgent 包含诺基亚足迹.如果是这样,请将 tel: 替换为 wtai://wp/mc;

Because of the wide support of the tel: protocol, I would suggest just use the tel: protocol. To support Nokia I would check if the navigator.userAgent contains Nokia footprint. If so, replace tel: to wtai://wp/mc;

如果您可以使用 jQuery,则 Javascript 可能如下所示:

If you can use jQuery, the Javascript could look something like:

if (/(Series60|Nokia)/i.test(navigator.userAgent)){
  $("a[href^='tel:']").each(function(){
    this.href = this.href.replace("tel:", "wtai://wp/mc;");
  });
}

这篇关于检测 HTML &lt;a&gt;Javascript 中的点击通话支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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