h5页面多端判断

  var u = navigator.userAgent,
    isAndroid = (u.indexOf('Android') > -1 || u.indexOf('Adr') > -1) ? true : false,
    isiOS = (u.indexOf('iPhone') > -1 || u.indexOf('iPad') > -1) ? true : false,
    isWeiXin = (u.toLowerCase().match(/MicroMessenger/i) == 'micromessenger') ? true : false,
    url = window.location.href,
    isinApp = (url.toLowerCase().indexOf("isinapp") > -1) ? true : false,
    firsturl = window.location.origin + "/",
    xqid = window.location.pathname.slice(7, -5),
    number_stId = window.location.pathname.indexOf("-goods");
  stId = window.location.pathname.slice(7, number_stId), opendappurl = '', scrchStr = '', time = new Date() * 1, session = window.sessionStorage, ifr = window.document.createElement("iframe");

  if (isAndroid) {
    //安卓嵌套
  } else if (isiOS) {
    //苹果嵌套
  };
  if (!isinApp) {//非小程序
    if (!isWeiXin) {//非微信
      if (isAndroid) {//非安卓
       
      } else if (isiOS) {//非iops

      };
    };
  };
原文地址:https://www.cnblogs.com/iqiao/p/12488901.html