移动端H5调起手机发短信功能
程序员文章站
2022-05-30 22:34:05
...
贴上代码
<script>
var u=navigator.userAgent;
var isAndroid=u.indexOf('Android')>-1||u.indexOf('Adr')>-1;
var isIOS=!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
var msg='hello world';
if(isAndroid){
// sms:后面跟收件人的手机号,body后接短信内容
window.location.href='sms:10086?body='+msg
}else if(isIOS){
window.location.href='sms:10086&body='+msg
}
</script>
可以在手机上点开以下网址进行查看
https://m.17shihui.com/staticPage/send-sms.html?msg=helloworld
同样如果使用按钮点击发送短信可以使用a标签
<a herf="sms:10086?body=helloworld">发送短信</a>
<a herf="sms:10086&body=helloworld">发送短信</a>
上一篇: ionic app版本更新
下一篇: ionic app自动更新