<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 参考地址