js判断浏览器及操作系统类型

ua = navigator.userAgent.toLowerCase(),
check = function(r){
    return r.test(ua);
},
isStrict = document.compatMode == "CSS1Compat",
isOpera = check(/opera/),
isChrome = check(/chrome/),
isWebKit = check(/webkit/),
isSafari = !isChrome && check(/safari/),
isSafari3 = isSafari && check(/version3/),
isSafari4 = isSafari && check(/version4/),
isIE = !isOpera && check(/msie/),
isIE7 = isIE && check(/msie 7/),
isIE8 = isIE && check(/msie 8/),
isGecko = !isWebKit && check(/gecko/),
isGecko3 = isGecko && check(/rv:1.9/),
isBorderBox = isIE && !isStrict,
isWindows = check(/windows|win32/),
isMac = check(/macintosh|mac os x/),
isAir = check(/adobeair/),
isLinux = check(/linux/)
原创文章:js判断浏览器及操作系统类型 ,未经许可,禁止转载,©版权所有
原文出处:前端开发博客 (http://caibaojian.com/js-browser.html)

发表评论

请登录后发表评论: