zoukankan      html  css  js  c++  java
  • 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{};

    琥珀君的博客
  • 相关阅读:
    开发错误记录2 .MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    开发错误记录1:解决:Only the original thread that created a view hierarchy can touch its views.
    第二篇 Python初识别及变量名定义规范
    第三篇 Python执行方式和变量初始
    第一篇 Python安装与环境变量的配置
    1. Linux系统常用操作
    Python的内存管理、命名规则、3个特性讲解
    操作系统及Python解释器工作原理讲解
    计算机基础小白篇
    Oracle SQL性能优化
  • 原文地址:https://www.cnblogs.com/eliteboy/p/10763944.html
Copyright © 2011-2022 走看看