H5判断环境 Android和IOS

H5判断环境 android和ios

  • 使用
console.log(‘环境判断‘,detect())
  • 代码
detect(){
	let equipmentType = "";
	let agent = navigator.userAgent.toLowerCase();
	let android = agent.indexOf("android");
	let iphone = agent.indexOf("iphone");
	let ipad = agent.indexOf("ipad");
	if(android != -1){
		equipmentType = "android";
	}
	if(iphone != -1 || ipad != -1){
		equipmentType = "ios";
	}
	return equipmentType;
}

H5判断环境 Android和IOS

上一篇:PTA basic 1018 锤子剪刀布 (20 分) c语言实现(gcc)


下一篇:android TextView 删除线