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

调用打电话接口

        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页面调用打电话和短信接口(可以传递短信内容))