javascript onClick - 拨打电话号码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11032489/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 11:52:49  来源:igfitidea点击:

onClick - call phone number

javascriptjqueryonclick

提问by user1016078

Possible Duplicate:
URL Scheme for Phone Call
iphone safari making phone call

可能的重复:
用于电话iphone safari 拨打电话的URL 方案

I am using the code below on a mobile site but when somebody clicks I don't want them directed to a new page I want a phone number to be called. Is this possible using the onClick function?

我在移动网站上使用下面的代码,但是当有人点击时,我不希望他们被定向到一个新页面,我想要一个电话号码。这可以使用 onClick 函数吗?

<div class="button left" id="map" onClick="window.location='#'"><span class="bottom">Call us now</span></div>

回答by Sujay

You should rather use something like

你应该使用类似的东西

<a href="tel:[phone number]"><span class="bottom">Call us now</span></a>