简体   繁体   English

如何在php网站中点击按钮触发电话?

[英]how to trigger a phone call on button click in a php website?

My client needed a hyperlink for a click to call feature so i include following line我的客户需要一个点击呼叫功能的超链接,所以我包括以下行

<a href="tel:917387084384">Call +91-7387084384</a>

However, requirements have changed from hyperlink to button, so need to know how to include click to call feature with a button但是,要求已从超链接更改为按钮,因此需要知道如何使用按钮包含点击呼叫功能

please let me know if you need any clarifications from my side.如果您需要我方面的任何说明,请告诉我。 thanks.谢谢。

您可以简单地将按钮的样式设置为与按钮完全一样,或者您可以使用onclick事件处理程序:

<button onclick="document.location.href = 'tel:917387084384'">Call +91-7387084384</button>

Step-by-step guide to turn a hyperlink into button:将超链接转换为按钮的分步指南:

  1. Rename the a tag into form and the href attribute into action :a标签重命名为form并将href属性重命名为action

    <form action="tel:917387084384">Call +91-7387084384</form>

  2. Wrap the text into a button tag:将文本包装成一个button标签:

    <form action="tel:917387084384"><button>Call +91-7387084384</button></form>

  3. Add the type attribute to the button tag and set it to submit :type属性添加到button标签并将其设置为submit

    <form action="tel:917387084384"><button type="submit">Call +91-7387084384</button></form>

And you're done!你完成了!

单击以下内容时,浏览器将要求您授予启动 Skype 的权限:

<button onclick="window.location='tel:917387084384';">Hot line</button>

It can also be called using document.createElement也可以使用document.createElement调用

function btnClick() {
  const linkElement = document.createElement("a")
  linkElement.href = 'tel:+123456789'
  linkElement.click()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM