从h5页面唤起相应app的方式总结

一、最新方法

    // 如果是iphone,直接使用universal link
    if (/iPhone|iPod|iPad/g.test(navigator.userAgent)) {
      location.href = "//dpl.qyer.com/app/guide?act=" + this.strType + "Detail" + "&id=" + this.id + "&auto=1"
    } else {
      // 安卓使用url scheme
      var appDetect = document.createElement('iframe');
      appDetect.id = 'app-detect';
      appDetect.style = 'display: none';
      appDetect.src = 'qyer://' + this.strType + '/detail/' + this.id;
      // 插入文档流,尝试打开APP
      document.body.appendChild(appDetect);
      // 移除探测器
      appDetect.remove();
    }

你可能感兴趣的:(前端工程化)