zoukankan      html  css  js  c++  java
  • leaflet开源地图库源码 浏览器&移动设备判断(browser.js)备份

    <script>
       var isIe = !-[1,];
      // alert('ie9 之前'+isIe);
       var ie = 'ActiveXObject' in window;
       //alert('sadsd'+ie);
       var ie2 = !!('ActiveXObject' in window);
       //alert('22222'+ie2);
       var ie3= !!window.ActiveXObject || !!("ActiveXObject" in window);   //!!window['ActiveXObject']  这个括号多了3个字符
    // alert(ie3);
     
     var doc = document.documentElement;
     console.log(doc.style+'查看支持的属性');
     ;(function () {
    
        var ua = navigator.userAgent.toLowerCase(),//var ua = navigator.userAgent.toLowerCase(); //window.navigator.userAgent,使用浏览器的UA判断,这里全部转为小写。如下图,在chrome中的判断。
            doc = document.documentElement,
    
            ie = 'ActiveXObject' in window,
    
            webkit    = ua.indexOf('webkit') !== -1,  // ///retina屏幕
            phantomjs = ua.indexOf('phantom') !== -1,
            android23 = ua.search('android [23]') !== -1,   ////是否是移动端android的2.3以上版本
            chrome    = ua.indexOf('chrome') !== -1,
    
            mobile = typeof orientation !== 'undefined',
            msPointer = navigator.msPointerEnabled && navigator.msMaxTouchPoints && !window.PointerEvent,
            pointer = (window.PointerEvent && navigator.pointerEnabled && navigator.maxTouchPoints) || msPointer,
    
            ie3d = ie && ('transition' in doc.style),
            webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23,
            gecko3d = 'MozPerspective' in doc.style,
            opera3d = 'OTransition' in doc.style;
    
       ///retina屏幕
        var retina = 'devicePixelRatio' in window && window.devicePixelRatio > 1;
    
        if (!retina && 'matchMedia' in window) {
            var matches = window.matchMedia('(min-resolution:144dpi)');
            retina = matches && matches.matches;
        }
        
    	
    	///触摸设备的验证:
        var touch = !window.L_NO_TOUCH && !phantomjs && (pointer || 'ontouchstart' in window ||
                (window.DocumentTouch && document instanceof window.DocumentTouch));
    
        L.Browser = {
            ie: ie,
            ielt9: ie && !document.addEventListener,
            webkit: webkit,
            gecko: (ua.indexOf('gecko') !== -1) && !webkit && !window.opera && !ie,
            android: ua.indexOf('android') !== -1,
            android23: android23,
            chrome: chrome,
            safari: !chrome && ua.indexOf('safari') !== -1,
    
            ie3d: ie3d,
            webkit3d: webkit3d,
            gecko3d: gecko3d,
            opera3d: opera3d,
            any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs,
    
            mobile: mobile,
            mobileWebkit: mobile && webkit,
            mobileWebkit3d: mobile && webkit3d,
            mobileOpera: mobile && window.opera,
    
            touch: !!touch,        //!!  快速转布尔值
            msPointer: !!msPointer,
            pointer: !!pointer,
    
            retina: !!retina
        };
    
    }());
    </script>

    源码清晰完善;备份不错;

    http://www.cnblogs.com/vczero/p/leaflet_3.html 参考地址

  • 相关阅读:
    KDrive 與 Embedded Linux
    windows内存管理初探
    开源方案
    boot time 优化
    psplash
    linux下操纵大于2G文件
    【技术贴】Windows图片和传真查看器打开图片慢,正在生成预览的解决办法!
    【转】c++.primer.plus.第五版.中文版[下载]
    【技术贴】魂斗罗坦克Normal Tanks第五关以及第5、6、7、关的LICENCE CODE的查
    【转】奇文共欣赏,疑义相与析:原文转载《电脑维护技巧》(N条举措N条理由)并请大家交流研讨
  • 原文地址:https://www.cnblogs.com/surfaces/p/4503128.html
Copyright © 2011-2022 走看看