日期:2014-05-16 浏览次数:20406 次
// Useragent RegExp rwebkit = /(webkit)[ \/]([\w.]+)/, ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, rmsie = /(msie) ([\w.]+)/, rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
// browser check-----start var userAgent = navigator.userAgent, // userAgent rMsie = /.*(msie) ([\w.]+).*/, // ie rFirefox = /.*(firefox)\/([\w.]+).*/, // firefox rOpera = /(opera).+version\/([\w.]+)/, // opera rChrome = /.*(chrome)\/([\w.]+).*/, // chrome rSafari = /.*version\/([\w.]+).*(safari).*/;// safari jMeteor.browser = {}; var ua = userAgent.toLowerCase(); function uaMatch(ua) { var match = rMsie.exec(ua); if (match != null) { return { browser : match[1] || "", version : match[2] || "0" }; } var match = rFirefox.exec(ua); if (match != null) { return { browser : match[1] || "", version : match[2] || "0" }; } var match = rOpera.exec(ua); if (match != null) { return { browser : match[1] || "", version : match[2] || "0" }; } var match = rChrome.exec(ua); if (match != null) { return { browser : match[1] || "", version : match[2] || "0" }; } var match = rSafari.exec(ua); if (match != null) { return { browser : match[2] || "", version : match[1] || "0" }; } if (match != null) { return { browser : "", version : "0" }; } } var browserMatch = uaMatch(userAgent.toLowerCase()); if (browserMatch.browser) { jMeteor.browser[browserMatch.browser] = true; jMeteor.browserName = browserMatch.browser; jMeteor.browser.version = browserMatch.version; jMeteor.browser.language = (navigator.language ? navigator.language : navigator.userLanguage || ""); } // browser check-----end
jMeteor.browser.msie //判断是否为ie,返回true则代表是 jMeteor.browserName //浏览器名称 jMeteor.browser.version //浏览器版本 jMeteor.browser.language //语言