Html href=tel:555 链接在移动 Safari 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7715388/
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
href=tel:555 link not working in mobile safari
提问by Iolo
I'm designing a mobile page and am using the following (standard, I believe) code to make the phone dial a phone number.
我正在设计一个移动页面,并使用以下(我相信是标准的)代码让电话拨打电话号码。
<a href="tel:555-1234567" class="call"><img src="graphics/call-icon.gif" alt="call-icon" width="45" height="50"></a>
This works fine in android but Mobile Safari I get the following error:
这在 android 中运行良好,但在 Mobile Safari 中出现以下错误:
Cannot Open Page
Safari cannot open the page because the address is invalid
无法打开页面
Safari 无法打开页面,因为地址无效
采纳答案by Ben
Your mark-up is fine, and it works on my iPhone (3GS, running 4.3.5). It doesn't work on the iOS simulator (yep, there's the "Cannot Open Page - Safari cannot open the page because the address is invalid" error), but then I wouldn't expect it to, given that you can't make calls on it (either that or the older version of iOS is at fault).
你的标记很好,它适用于我的 iPhone(3GS,运行 4.3.5)。它在 iOS 模拟器上不起作用(是的,有“无法打开页面 - Safari 无法打开页面,因为地址无效”错误),但我不希望它,因为你不能调用它(那个或旧版本的iOS有问题)。
回答by chown
In your <head>
put:
在你的<head>
投入:
<meta name="format-detection" content="telephone=yes">
From Safari HTML Reference:
This Enables or disables automatic detection of possible phone numbers in a webpage in Safari on iOS. Syntax Discussion By default, Safari on iOS detects any string formatted like a phone number and makes it a link that calls the number. Specifying telephone=no disables this feature. Availability Available in iOS 1.0 and later. Support Level Apple extension.
这在 iOS 上的 Safari 中启用或禁用网页中可能的电话号码的自动检测。语法讨论 默认情况下,iOS 上的 Safari 会检测任何格式为电话号码的字符串,并将其设为调用该号码的链接。指定 phone=no 禁用此功能。可用性 在 iOS 1.0 及更高版本中可用。支持级别 Apple 扩展。
回答by James Williams
for a telephone number to work in Safari/iOS you need to format the telephone properly like it would be listed in an old ad.
要在 Safari/iOS 中使用电话号码,您需要正确格式化电话,就像旧广告中列出的那样。
<a href="tel:1-555-123-4567" class="call">
----- OR -----
<a href="tel:15551234567" class="call">
回答by ArchyBean
回答by Bryan Labuschagne
If you still have a problem with your telephone number not showing up on safari i had the exact same problem, i picked up that if you do not use a web friendly font it will not display try and change your font for the number to Verdana or Arial. I used google web font which should be web friendly but even that broke my number.
如果您的电话号码仍然没有出现在 safari 上的问题,我遇到了完全相同的问题,我发现如果您不使用网络友好字体,它将不会显示尝试将您的号码字体更改为 Verdana 或宋体。我使用了应该对网络友好的谷歌网络字体,但即使这样也破坏了我的号码。
Hope this works.
希望这有效。
回答by Muhammad Russell
The following worked for me, hope it helps.
以下对我有用,希望它有所帮助。
<a href="javascript:void(0)" onclick="window.location='tel:8005555555'" class="call">800 555 5555</a>
It should work on both ios chrome and safari.
它应该适用于 ios chrome 和 safari。