由于新版iPad浏览器没有带有iPad字符串,导致iPad会判断成电脑端,
var ua = navigator.userAgent;
var isSafari = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1;
var isIphone = ua.indexOf("iPhone") != -1 && ua.indexOf("Version") != -1
var isIPad = isSafari && !isIphone && 'ontouchend' in document;
if (!/iphone|ios|ipad|android|mobile/i.test(navigator.userAgent.toLowerCase()) && !isIPad) {
// location.href = "qr.html?url=" + encodeURIComponent(location.href);
alert("pc")
}
判断机型的 ipad的 用上面的
const sUserAgent = navigator.userAgent.toLowerCase();
const bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
const bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
const bIsMidp = sUserAgent.match(/midp/i) == "midp";
const bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
const bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
const bIsAndroid = sUserAgent.match(/android/i) == "android";
const bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
const bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (bIsAndroid) {
return true
} else {
return false
}