Html 如何创建超链接以在移动设备上拨打电话号码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13662175/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:10:26  来源:igfitidea点击:

How to create hyperlink to call phone number on mobile devices?

htmlmobilehyperlink

提问by JROB

What is the proper, universal format for creating a clickable hyperlink for users on mobile devices to call a phone number?

为移动设备上的用户创建可点击的超链接以拨打电话号码的正确通用格式是什么?

Area code with dashes

带破折号的区号

<a href="tel:555-555-1212">555-555-1212</a>

Area code with no dashes

没有破折号的区号

<a href="tel:5555551212">555-555-1212</a>

Area code with dashes and 1

带破折号和 1 的区号

<a href="tel:1-555-555-1212">555-555-1212</a>

Area code with no dashes and 1

没有破折号和 1 的区号

<a href="tel:15555551212">555-555-1212</a>

Area code with dashes, 1 and + sign

带破折号、1 和 + 号的区号

<a href="tel:+1-555-555-1212">555-555-1212</a>

Area code with no dashes, 1 and + sign

不带破折号、1 和 + 号的区号

<a href="tel:+15555551212">555-555-1212</a>

采纳答案by Mike

Dashes (-) have no significance other than making the number more readable, so you might as well include them.

破折号 ( -) 除了使数字更具可读性之外没有任何意义,因此您不妨包含它们。

Since we never know where our website visitors are coming from, we need to make phone numbers callable from anywhere in the world. For this reason the +sign is always necessary. The +sign is automatically converted by your mobile carrier to your international dialing prefix, also known as "exit code". This code varies by region, country, and sometimes a single country can use multiple codes, depending on the carrier. Fortunately, when it is a local call, dialing it with the international format will still work.

由于我们永远不知道我们的网站访问者来自哪里,因此我们需要使电话号码可以从世界任何地方拨打。为此,+标志总是必要的。该+标志由您的移动运营商自动转换为您的国际拨号前缀,也称为“退出代码”。此代码因地区、国家/地区而异,有时一个国家/地区可以使用多个代码,具体取决于运营商。幸运的是,当是本地电话时,使用国际格式拨号仍然有效。

Using your example number, when calling from China, people would need to dial:

使用您的示例号码,从china拨打电话时,人们需要拨打:

00-1-555-555-1212

And from Russia, they would dial

从俄罗斯,他们会拨打

810-1-555-555-1212

The +sign solves this issue by allowing you to omit the international dialing prefix.

+标志通过允许您省略国际拨号前缀来解决此问题。

After the international dialing prefix comes the country code(pdf), followed by the geographic code (area code), finally the local phone number.

在国际拨号前缀之后是国家代码(pdf),然后是地理代码(区号),最后是本地电话号码。

Therefore either of the last two of your examples would work, but my recommendation is to use this format for readability:

因此,您的最后两个示例中的任何一个都可以使用,但我的建议是使用这种格式以提高可读性:

<a href="tel:+1-555-555-1212">+1-555-555-1212</a>

Note:For numbers that contain a trunk prefixdifferent from the country code (e.g. if you write it locally with brackets around a 0), you need to omit it because the number must be in international format.

注意:对于包含与国家/地区代码不同的中继前缀的号码(例如,如果您在本地用括号括起来 a 编写0),您需要省略它,因为号码必须是国际格式。

回答by Ravindra Bagale

-doesnt make matter but +sign is important when mobile user is in roaming
this is the standard format

-无关紧要,+但当移动用户漫游时,标志很重要,
这是标准格式

<a href="tel:+4917640206387">+49 (0)176 - 402 063 87</a>

You can read more about it in the spec, see Make Telephone Numbers "Click-to-Call".

您可以在规范中阅读有关它的更多信息,请参阅拨打电话号码“点击通话”

回答by molaro

I also found this format online, and used it. Seems to work with or without dashes. I have verified it works on my Mac (tries to call the number in FaceTime), and on my iPhone:

我也在网上找到了这种格式,并使用了它。似乎可以使用或不使用破折号。我已经验证它适用于我的 Mac(尝试在 FaceTime 中拨打号码)和我的 iPhone:

<!-- Cross-platform compatible (Android + iPhone) -->
<a href="tel://1-555-555-5555">+1 (555) 555-5555</a>

回答by trifase

I used:

我用了:

Tel: <a href="tel:+123 123456789">+123 123456789</a>

and the result is:

结果是:

Tel: +123 123456789

电话:+123 123456789

Where "Tel:" stands for pure text and only the number is coded and clickable.

其中“电话:”代表纯文本,只有数字被编码和可点击。

回答by Chance

You can also use callto:########### replacing the email code mail with call, at least according to W3Cschool site but I haven't had an opportunity to test it out.

您还可以使用 callto:########### 用 call 替换电子邮件代码邮件,至少根据 W3Cschool 站点,但我还没有机会对其进行测试。