JS判断访问这个页面是win还是Android IOS来源

window.onload = function(){
var system ={
win : false,
mac : false,
xll : false
};
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
var ios = document.getElementById("ios");
var andriod = document.getElementById("andriod");
if(system.win||system.mac||system.xll){
// ios.style.right = 460+"px";
// ios.style.bottom = 120+"px";
// andriod.style.right = 330+"px";
// andriod.style.bottom = 120+"px";
}else{
var sUserAgent = navigator.userAgent.toLowerCase();
var isIOS = sUserAgent.match(/mac/i) == "mac";
var isIphone = sUserAgent.match(/iphone/i) == "iphone";
var isIpad = sUserAgent.match(/ipad/i) == "ipad";
var isAndroid = sUserAgent.match(/android/i) == "android";
if(isAndroid){
//window.location.href=‘http://api.eguotong.cn/download/android.apk‘;
}else if(isIOS || isIpad || isIphone){
//window.location.href=‘https://appsto.re/cn/4NI-2.i‘;
}else {
ios.style.right = 460+"px";
ios.style.bottom = 120+"px";
andriod.style.right = 330+"px";
andriod.style.bottom = 120+"px";
}
}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。