javascript 如何在php网站中点击按钮触发电话?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23857507/
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
how to trigger a phone call on button click in a php website?
提问by Bhavik
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.
如果您需要我方面的任何说明,请告诉我。谢谢。
回答by Joeytje50
You could simply style the button to look exactly like a button, or you could use an onclick
event handler:
您可以简单地将按钮的样式设置为与按钮完全一样,或者您可以使用onclick
事件处理程序:
<button onclick="document.location.href = 'tel:917387084384'">Call +91-7387084384</button>
回答by hakre
Step-by-step guide to turn a hyperlink into button:
将超链接转换为按钮的分步指南:
Rename the
a
tag intoform
and thehref
attribute intoaction
:<form action="tel:917387084384">Call +91-7387084384</form>
Wrap the text into a
button
tag:<form action="tel:917387084384"><button>Call +91-7387084384</button></form>
Add the
type
attribute to thebutton
tag and set it tosubmit
:<form action="tel:917387084384"><button type="submit">Call +91-7387084384</button></form>
将
a
标记重命名为form
,将href
属性重命名为action
:<form action="tel:917387084384">Call +91-7387084384</form>
将文本包装成一个
button
标签:<form action="tel:917387084384"><button>Call +91-7387084384</button></form>
将
type
属性添加到button
标记并将其设置为submit
:<form action="tel:917387084384"><button type="submit">Call +91-7387084384</button></form>
And you're done!
大功告成!
回答by oabarca
The following will make the browser ask you for permission to launch Skype when clicked:
单击以下内容时,浏览器将要求您授予启动 Skype 的权限:
<button onclick="window.location='tel:917387084384';">Hot line</button>