是否可以通过编程方式用JS拨打电话号码? [英] Is it possible to programmatically call a telephone number in JS?

查看:107
本文介绍了是否可以通过编程方式用JS拨打电话号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,基本上现在,我可以创建一个带有A标签的按钮,该标签具有href ="tel:XXXXXXXXXXX",如果用户单击/轻击该按钮,则会将其带入他们的电话应用程序.但是,我正在尝试以编程方式在手势识别(滑动)上执行此操作.该手势有效,到目前为止,我已经尝试过window.location = "tel:XXXXXXXXXX"; window.open('tel:XXXXXXXXXX', '_top');

两个都没有起作用.任何的想法?离子/角1

注意**它似乎仅在iOS上发生,Android似乎运行良好.

解决方案

如果您想通过html进行操作,则只需放置如下标记:

<a href="tel:XXXXXXXXXX">Call me!</a>

类似地,如果您想通过javascript进行操作,则可以这样做:

document.location.href = "tel:XXXXXXXXXX";

So basically right now I can create a button with an A tag that has an href="tel:XXXXXXXXXXX" and if a user clicks / taps on that it will bring them into their phone application. However I am trying to do this programmatically on gesture recognition (swipe). The gesture is working, so far I have tried window.location = "tel:XXXXXXXXXX"; window.open('tel:XXXXXXXXXX', '_top');

neither of which have worked yet. Any idea? Ionic / Angular 1

Note** It appears to only happen on iOS, Android seems to be working fine.

解决方案

If you want to do it through html, then you just have to place a tag like this:

<a href="tel:XXXXXXXXXX">Call me!</a>

similarly if you wanna do it through javascript, you can do:

document.location.href = "tel:XXXXXXXXXX";

这篇关于是否可以通过编程方式用JS拨打电话号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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