onClick - call phone number [duplicate]

2019-09-01 06:48发布

问题:

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

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?

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

回答1:

You should rather use something like

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