首页 > 代码库 > JS判断访问这个页面是win还是Android IOS来源
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://www.mamicode.com/‘http://api.eguotong.cn/download/android.apk‘;
}else if(isIOS || isIpad || isIphone){
//window.location.href=http://www.mamicode.com/‘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";
}
}
JS判断访问这个页面是win还是Android IOS来源