【问题标题】:Trigger phone call with Javascript用Javascript触发电话
【发布时间】:2013-05-22 19:37:25
【问题描述】:

我想仅使用 Javascript 而不是锚点来触发 tel:12345 HREF。我只是想获取输入字段的值并使用 JS 提示用户拨打输入的号码。我的触发器将是位于字段旁边的按钮。

建议?

【问题讨论】:

标签: javascript tel


【解决方案1】:

用途:

window.open('tel:12345');

【讨论】:

  • 这是最好的解决方案还是window.location.href='tel:12345';,哪个更好?
  • @adrianTNT 我更喜欢您的解决方案,因为它不会打开新窗口或标签。它只是从当前窗口进行调用。
【解决方案2】:
<button onclick="myFunction()">
Call
</button>

function myFunction(){
var a = document.getElementById('input').value;
window.location.href = 'tel:' + a;
}
You can also view the live version on my website:
https://www.theharnishes.com/phone.html

Here we make a button and assign a function to it that bassically select the input, get the value, and the window.location.href will have the value of the input and it'll sent the url to call any number. 

【讨论】:

  • 请不要只发布代码作为答案,还要解释您的代码的作用以及它如何解决问题的问题。带有解释的答案通常更有帮助、质量更好,并且更有可能吸引投票。
【解决方案3】:

js调用非常简单。 使用我们的:onclick 函数、Location 和 tel 我们可以在任何标签中执行此操作, 窗户 。位置('电话:号码')

点我拨打199

【讨论】:

  • 请在您的回答中提供更多详细信息。正如目前所写的那样,很难理解您的解决方案。
猜你喜欢
  • 2019-10-14
  • 2021-04-25
  • 1970-01-01
  • 2016-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多