美文网首页
h5页面调用打电话和短信接口(可以传递短信内容)

h5页面调用打电话和短信接口(可以传递短信内容)

作者: 装在壳子里的刺猬 | 来源:发表于2019-09-16 09:07 被阅读0次

    调用打电话接口

            var phone =$('#phonecall').val();
            window.location.href = "tel:" + phone;
    

    调用发短信接口

          //用户的电话号码
           var phone =$('#messagecall').val();
          //发送短信的内容
            var name=$('.message_content').html();
            var u = navigator.userAgent, app = navigator.appVersion;
            var isAndroid = u.indexOf('Android') > -1
                || u.indexOf('Linux') > -1; //android终端或者uc浏览器
            var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
                || u.indexOf('iPhone') > -1; //ios终端
            if (isAndroid) {
                var sendcontent = 'sms:' + phone + '?body='+name;//android  ///
                window.location.href = sendcontent;
            } else if (isiOS) {
                var sendcontent = 'sms:' + phone + '&body='+name;//ios  ///
                window.location.href = sendcontent;
            } else {
                var sendcontent = 'sms:' + phone + '?body='+name;//android  ///
                window.location.href = sendcontent;
            }
        }
    

    相关文章

      网友评论

          本文标题:h5页面调用打电话和短信接口(可以传递短信内容)

          本文链接:https://www.haomeiwen.com/subject/atjqyctx.html