//判断当前是否为安卓OR苹果
function detect(){
var equipmentType = "";
var agent = navigator.userAgent.toLowerCase();
var android = agent.indexOf("android");
var iphone = agent.indexOf("iphone");
var ipad = agent.indexOf("ipad");
if(android != -1){
equipmentType = "android";
}
if(iphone != -1 || ipad != -1){
equipmentType = "ios";
}
return equipmentType;
}
equipmentType返回值为ios代表当前为苹果手机
equipmentType返回值为andriod代表当前为安卓手机
//判断当前是否为PC端
function isPC() {
var a = /macintosh|window/.test(navigator.userAgent.toLowerCase());
if(/chrome/.test(navigator.userAgent.toLowerCase())) {
a = true
}
return a
}
//判断当前是否为app内环境
function isApp(a, b) {
b = b || navigator.userAgent;
if(a === "wx") {
return(/micromessenger/i.test(b))
}
if(a === "qq") {
return(/qq\//i.test(b))
}
if(a === "weibo") {
return(/weibo/i.test(b))
}
return false
}