在移动端页面开发中,偶尔会需要唤起用户手机的打电话功能,拨打客服电话,此时我们可以按照以下操作实现打电话功能:
1)index.html在<head></head>中加入这一段:
<meta name="format-detection" content="telephone=yes"/>
2)js中设置点击事件:
window.location.href = 'tel:4000-000-000';
或者直接使用:
<a href="tel:4000-000-000">拨打电话</a>
若涉及到发送短信可以设置:
// 添加内容
window.location.href = 'sms:10086?body=短信内容';
// 不添加内容
window.location.href = 'sms:10086';
或者:
<a href="sms:10086">发送短信</a>
<a href="sms:10086?body=短信内容"></a>
文章参考:https://blog.csdn.net/Boale_H/article/details/108582436