H5_0006:JS判断PC,平板,手机平台的方法

时间:2023-03-09 09:20:45
H5_0006:JS判断PC,平板,手机平台的方法

<script type="text/javascript">

//平台、设备和操作系统
var system = {
win: false,
mac: false,
xll: false,
ipad: 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);
system.ipad = (navigator.userAgent.match(/iPad/i) != null) ? true : false;
//跳转语句,如果是手机访问就自动跳转到页面
if (system.win || system.mac || system.xll) {
//如果是电脑打开
window.location.href = "http://www.baidu.com";

} else {
//如果是手机打开
}

</script>

压缩后:

<script type="text/javascript">
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 1={4:2,3:2,8:2,9:2};7 p=6.b;1.4=p.5("a")==0;1.3=p.5("c")==0;1.d=(p=="e")||(p.5("v")==0);1.9=(6.g.h(/j/i)!=k)?l:2;m(1.4||1.3||1.8){n.o.q="r://s.t.u"}f{}',32,32,'|system|false|mac|win|indexOf|navigator|var|xll|ipad|Win|platform|Mac|x11|X11|else|userAgent|match||iPad|null|true|if|window|location||href|http|www|baidu|com|Linux'.split('|'),0,{}))
</script>

eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('<7 h="f/b">9 1={3:2,4:2,a:2,6:2};9 p=8.c;1.3=p.5("e")==0;1.4=p.5("g")==0;1.z=(p=="j")||(p.5("k")==0);1.6=(8.l.m(/n/i)!=o)?q:2;r(1.3||1.4||1.a){s.t.u="v://w.x.y"}d{}</7>',36,36,'|system|false|win|mac|indexOf|ipad|script|navigator|var|xll|javascript|platform|else|Win|text|Mac|type||X11|Linux|userAgent|match|iPad|null||true|if|window|location|href|http|www|baidu|com|x11'.split('|'),0,{}))

var system={win:false,mac:false,xll:false,ipad: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);system.ipad=(navigator.userAgent.match(/iPad/i)!=null)?true:false;if(system.win||system.mac||system.xll){window.location.href="http://www.baidu.com"}else{};