Skip to content
Permalink
Browse files
Update src/deprecated.js
Determine the browser better way
Do not need to use userAgent
  • Loading branch information
gucong3000 committed Jan 14, 2013
1 parent 6c29dd2 commit 139903496a544e1211a71096bc8c1b5369789160
Showing with 33 additions and 2 deletions.
  1. +33 −2 src/deprecated.js
@@ -1,4 +1,35 @@
// Limit scope pollution from any deprecated API
// (function() {
(function() {
var browser = {};

// })();
//IE特有的条件编译,勿当做注释删除
if(/*@cc_on!@*/0){
browser.msie = document.documentMode || (document.compatMode == "CSS1Compat" ? "XMLHttpRequest" in window ? 7 : 6 : 5);
navigator.language = navigator.userLanguage;
} else if ( window.opera ) {
//Opera
browser.opera = opera.version();
navigator.language = navigator.language.replace(/-\w+$/, function(str ) {
return str.toUpperCase();
});

} else if ( window.netscape && navigator.product == "Gecko" ) {
//Firefox
browser.gecko = true;
} else {
//WebKit
browser.webkit = true;

if(window.chrome){
//判定为Chrome
browser.chrome = true;
} else if(/^apple\s+/i.test(navigator.vendor)) {
//判定为Safari
browser.safari = true;
}

}

jQuery.browser = browser;

})();

0 comments on commit 1399034

Please sign in to comment.