在移动端页面开发中,偶尔会需要唤起用户手机的打电话功能,拨打客服电话,此时我们可以按照以下操作实现打电话功能:

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://www.jianshu.com/p/7b4ae5d94276
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

相关文章:

  • 2022-12-23
  • 2021-08-14
  • 2021-12-16
  • 2021-12-31
  • 2022-01-17
  • 2022-01-29
  • 2022-01-14
  • 2022-12-23
猜你喜欢
  • 2021-10-01
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
相关资源
相似解决方案