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;
        }
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容