android/iphone点击在html中调用

发布于 2024-12-11 11:44:04 字数 315 浏览 0 评论 0原文

我正在为 Android 和 Android 创建一个 HTML 移动网站iOS 设备。 我知道点击呼叫两者。

ANDROID

<a href="tel:2125551212">2125551212</a>

iOs

<a href="callto:2821229627-7877">Live Support</a>

现在,我的问题是我有一个带有点击通话链接的网页,并且希望该链接适用于 android / ios

I am creating one HTML mobile website for android & ios device.
I know click to call for both.

ANDROID

<a href="tel:2125551212">2125551212</a>

iOs

<a href="callto:2821229627-7877">Live Support</a>

Now, my problem is i have one webpage with click to call link and want that link work for both android / ios

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

懒的傷心 2024-12-18 11:44:04

只需使用 tel: 即可在 iOS、Android、blackbarry 操作系统、Windows 等上运行。使用此方案将适用于几乎所有移动浏览器。

Just use tel: it will work on iOS, android, blackbarry OS, windows and many more. Using this scheme will work on almost all mobile browsers on.

很酷又爱笑 2024-12-18 11:44:04

你必须认识客户。由于不同的手机有不同的用户代理,您可以使用 JavaScript 执行以下操作:

if (navigator.userAgent.indexOf("Android") != -1) {
    txt = "<a href="tel:2125551212">2125551212</a>";
} else if (navigator.userAgent.indexOf("iPhone") != -1) {
    txt = "<a href="callto:2821229627-7877">Live Support</a>";
}

You have to recognize the client. Since different phones have different user agents, you can do something like this with JavaScript:

if (navigator.userAgent.indexOf("Android") != -1) {
    txt = "<a href="tel:2125551212">2125551212</a>";
} else if (navigator.userAgent.indexOf("iPhone") != -1) {
    txt = "<a href="callto:2821229627-7877">Live Support</a>";
}
客…行舟 2024-12-18 11:44:04

这对我也有用。

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

这样做的问题是它会破坏人们可能在桌面浏览器上使用的附加组件和扩展。

对于 Android 操作系统,点击后即可拨打普通电话号码。

<p>212-555-1212</p>

您还可以使用 AdWords 跟踪此通话。我正在努力让它与 Google Analytics 一起使用。

This works for me as well.

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

The problem with this is it will break add-ons and extensions that people may use on desktop browsers.

The plain phone number will call on click for Android OS.

<p>212-555-1212</p>

You can also track this call with AdWords. I am working on getting it to work with Google Analytics.

沉睡月亮 2024-12-18 11:44:04

关于 MoyShe 的帖子而不是窃取她的代码(补充),我将使用默认的 else 语句为桌面浏览器和其他浏览器添加条件默认值。

if (navigator.userAgent.indexOf("Android") != -1) {
txt = "<a href="tel:2125551212">2125551212</a>";
} else if (navigator.userAgent.indexOf("iPhone") != -1) {
txt = "<a href="callto:2821229627-7877">Live Support</a>";
}
<!--what about other devices OS-->
else {
txt = "<span><strong>Phone -</strong> 282-122-9627 ext.7877</span>";
}

这样,桌面浏览器用户还可以看到电话号码,因为如果该设备不属于所查询的两个手持设备,则默认情况下会显示电话号码。

我不熟悉android、blackberry、IO、windows等...但我也想问或指出我的评论部分。

<!--what about other devices OS-->

(对于 Newbs - 粘贴到网页中时可以删除上面的注释代码行)。

黑莓和所有其他设备操作系统呢?它们是 Android 还是 IO 驱动的操作系统?如果不是,还需要创建专门识别这些设备的附加代码并将其包含在(else if)语句中。

如果我的未知问题是正确的,Switch/Case 语句可能会更干净,也是更好的方法。

In regards to MoyShe's post and not to steal her code (complements) I would add a conditional default for Desktop browsers and other as well using a default else statement.

if (navigator.userAgent.indexOf("Android") != -1) {
txt = "<a href="tel:2125551212">2125551212</a>";
} else if (navigator.userAgent.indexOf("iPhone") != -1) {
txt = "<a href="callto:2821229627-7877">Live Support</a>";
}
<!--what about other devices OS-->
else {
txt = "<span><strong>Phone -</strong> 282-122-9627 ext.7877</span>";
}

That way desktop browsers users could also see a phone number as it would display a phone number by default if the device is not of the two handheld device queried.

I am not versed in android, blackberry, IOs, windows, etc...but I would also like to ask or point out my comment section.

<!--what about other devices OS-->

(For Newbs- the above line of commented code can be removed when pasting in the web page).

What about blackberry and all the other device OS's? Are they Android or IOs driven OS's? If not, additional code to specifically identify those devices would also need to be created and included in the (else if's) statements.

If I am correct in my unknown question, a Switch/Case statement might be cleaner and a better way to go.

内心旳酸楚 2024-12-18 11:44:04

如上
Msaccess 澳大利亚帮助www.msaccess.com.au
您只想在 PC 浏览器上显示普通文本
因此,将此行放入您的页面

文件中

var ua = navigator.userAgent.toLowerCase(); 
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf      ("mobile");

if (isAndroid)
{document.write('<a class="mobilesOnly" href="tel:++61476132591"> Click here to call tel:++61476132591</a>');}
else
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i))) 
{document.write('<a class="mobilesOnly" href="tel:++61476132591"> Click here to call now:  tel:++61476132591</a>');}
else 
{document.write('Call ++61476132591') ;}

并将以下内容保存在名为 javascript.js的 别忘了更改号码:)

as on
Msaccess Help Australia www.msaccess.com.au
You only want ordinary text showing on a PC browsers
so put this line in your page

<script type="text/javascript" src="javascript.js"></script>

and save the below in a file called javascript.js

var ua = navigator.userAgent.toLowerCase(); 
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf      ("mobile");

if (isAndroid)
{document.write('<a class="mobilesOnly" href="tel:++61476132591"> Click here to call tel:++61476132591</a>');}
else
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i))) 
{document.write('<a class="mobilesOnly" href="tel:++61476132591"> Click here to call now:  tel:++61476132591</a>');}
else 
{document.write('Call ++61476132591') ;}

don't forget to change the number :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文