java : Java judgment Browser type public static Boolean Isie () {return servletactioncontext.getrequest (). g Etheader ("User-agent"). toLowerCase (). IndexOf ("MSIE") > 0? True:false; }
javascript:
Safari
Safari browser has a opendatabase function that is not available in other browsers and can be used as a marker for safari.
Safari's typical useragent is as follows:
mozilla/5.0 (Windows; U Windows NT 5.2) applewebkit/525.13 (khtml, like Gecko) version/3.1 safari/525.13
mozilla/5.0 (IPhone; U CPU like Mac OS X) applewebkit/420.1 (khtml, like Gecko) version/3.0 mobile/4a93 safari/419.3
The version number is the number after version.
Chrome
Chrome has a messageevent function, but Firefox does. However, the good news is that Chrome does not have Firefox's getboxobjectfor function, which can be used to accurately determine the Chrome browser.
At present, the useragent of Chrome is:
mozilla/5.0 (Windows; U Windows NT 5.2) applewebkit/525.13 (khtml, like Gecko) chrome/0.2.149.27 safari/525.13
Where the version number is after the chrome number.
Interestingly, Chrome's useragent also includes Safari features, which is perhaps the basis for all of the apps that Chrome can run on Apple's browser.
Navigator
At present, the useragent of Navigator is:
mozilla/5.0 (Windows; U Windows NT 5.1; En-us; rv:1.8.1.12) gecko/20080219 firefox/2.0.0.12 navigator/9.0.0.6
Where the number of the version number after the navigator.
By looking at the differences in the above browsers, you can use JavaScript to distinguish between browsers, but not to determine whether or not to be compatible with the ExtJS, look at the source code, found that there is a browser type and version and operating system judgments.
The source code is as follows:
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 (/version//3/),
IsSafari4 = Issafari && Check (/version//4/),
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/)
About Document.compatmode
The rendering of the box model in IE is very different from the standards mode and quirks mode, and the interpretation of the box model under Standards mode is the same as that of other standard browsers, but in quirks mode, there is a big difference. In the case of not declaring doctype, IE defaults to quirks mode. So for compatibility reasons, we might need to get the current document rendering mode.
Document.compatmode, which comes in handy, has two possible return values: Backcompat and Css1compat, interpreted as follows:
Backcompat standards-compliant mode isn't switched on. (Quirks Mode)
Css1compat standards-compliant mode is switched on. (Standards Mode)
In the actual project, we also need to get browse whether IE, so we can get IE rendering mode. Code in ExtJS: Isborderbox=isie&&!isstrict.
When a document has a standard declaration, the value of the Document.compatmode equals "Css1compat", so we can determine whether the document adds a standard declaration based on the Document.compatmode value.
var height = document.compatmode== "Css1compat"? Document.documentElement.clientHeight:document.body.clientHeight;