Html 为移动浏览器设置电话链接的可靠方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4169976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's a reliable method for setting up telephone links for mobile browsers?
提问by Surreal Dreams
I'm working on a quick page intended for mobile browsers. While there is little consistency between browsers on cell phones (the target audience), I have a phone number that I would like to be as easy as possible to dial from the users phone. A link seems the obvious choice; so I set up the following:
我正在为移动浏览器设计一个快速页面。虽然手机上的浏览器(目标受众)之间几乎没有一致性,但我有一个电话号码,我希望尽可能轻松地从用户电话拨打。链接似乎是显而易见的选择;所以我设置了以下内容:
<a href="tel:+18881235467">1-888-123-5467</a>
This seems to work OK on more advanced browsers such as the Android & BlackBerry browsers, it's a lot less reliable on other phones. Any advice on making this link work consistently and or correctly will be greatly appreciated.
这在更高级的浏览器(例如 Android 和 BlackBerry 浏览器)上似乎可以正常工作,但在其他手机上的可靠性要低得多。任何有关使此链接始终如一或正确工作的建议将不胜感激。
FYI, this is a toll free domestic US call, but I imagine that some devices may be looking for a more general format.
仅供参考,这是美国国内的免费电话,但我想有些设备可能正在寻找更通用的格式。
采纳答案by Surreal Dreams
What I eventually came up with was a link that worked like this:
我最终想出了一个像这样工作的链接:
<a href="wtai://wp/mc;18881235467">1-888-123-4567</a>
This has worked on every phone tested so far, including Android, BlackBerry and some veryclunky older phones. From what I gather, the structure of the link works like so:
到目前为止,这适用于所有测试过的手机,包括 Android、黑莓和一些非常笨重的旧手机。据我所知,链接的结构如下所示:
WTAI references the Wireless Telephony Application Interface. The wp/ refers to the WTAPublic functions. The mc; is the makeCall function, and then of course you have the phone number. Similarly, you can do a link like this:
WTAI 引用无线电话应用程序接口。wp/ 指的是 WTAPublic 函数。麦克; 是makeCall函数,然后当然你有电话号码。同样,你可以做一个这样的链接:
<a href="wtai://wp/ap;18881235467">Add to addressbook: 1-888-123-4567</a>
This is the same except mc; has been replaced by ap;, which refers to the addPBEntry function. This adds the phone number to your address book or similar stash of phone numbers.
除了 mc 之外,这是相同的;已被 ap; 取代,它指的是 addPBEntry 函数。这会将电话号码添加到您的地址簿或类似的电话号码存储中。
These two sites were helpful in my research:
这两个网站对我的研究很有帮助:
回答by Mick
The approach you are using is the 'standard' way to do this (i.e follows RFC 3966). If a mobile browser does not interpret it correctly, the only obvious way to fix this would be to extend or modify the browsers behavior itself, which you probably do not want to do or have access to do.
您使用的方法是执行此操作的“标准”方法(即遵循RFC 3966)。如果移动浏览器不能正确解释它,解决此问题的唯一明显方法是扩展或修改浏览器行为本身,而您可能不想这样做或无权这样做。
I believe it is supported on Windows devices (mobile explorer), iPhone (safari), Symbian and from what you are saying Blackberry and Android.
我相信 Windows 设备(移动浏览器)、iPhone(Safari)、Symbian 以及您所说的 Blackberry 和 Android 都支持它。
Are you finding problems with theses devices or are you supporting other mobile phones also?
您是否发现这些设备存在问题,或者您是否也支持其他手机?
Note that others seem to be having the opposite problem with iPhone and iPad as the default browser (Safari) changes anything that looks like a phone number into a link:
请注意,其他人似乎在 iPhone 和 iPad 上遇到了相反的问题,因为默认浏览器 (Safari) 会将任何看起来像电话号码的内容更改为链接:
回答by Angela
I've seen big sites like yelp use a different method for accomplishing this, where they use vcard and tel classes:
我见过像 yelp 这样的大网站使用不同的方法来实现这一点,他们使用 vcard 和 tel 类:
http://microformats.org/wiki/hcard
http://microformats.org/wiki/hcard
<div class="vcard">
<span class="tel">(555) 555-5555</span>
</div>