In addition to its own method, it is certainly not to use navigator. useragent to determine the browser. In the early days of the first browser war, Netscape was an absolute statistical position. Most people were reluctant to be compatible with other browsers and checked its UA to allow their websites to only access Netscape, this forces other browsers (including IE) to modify their UA to pretend to be Netscape to use self-righteous scripts, so everyone claims that they are others, even the UA of the latest ie9 is:
//Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)
The following are some of my collected or original judgments:
// IE8 new features list: http://www.cnblogs.com/rubylouvre/articles/1716755.html//2010 4 16 update ie678 =! + "\ V1"; ie678 =! -[1,]; // ie678 = '\ V' = 'V'; ie678 = ('a ~ B '. Split (/(~) /) [1] = "B" ie678 = 0.9.tofixed (0) = "0" IE8 = Window. tostatichtml ie9 = Window. msperformance Ie = !! Document. recalc Ie = !! Window. vbarray Ie = !! Window. activexobject ie678 = 0 // @ cc_on + 1; Ie = !! Window. createpopup; Ie =/* @ cc_on! @*/! 1; Ie = document. expando; // document. all also has Ie =/\ W/in the earlier versions of opera Firefox /. test ('\ u0130') // IE6 = is provided by the ABCD in the group! "1" [0] // IE6 or ie5 strings cannot use the attribute IE8 = !! Window. xdomainrequest; ie9 = document.doc umentmode & document.doc umentmode = 9; // self-developed, conditional-compiled sniffing script. ie returns the JS engine version number, 0 var ieversion = eval ("'' +/* @ cc_on "+" @ _ jscript_version @ */-0 ") is returned for non-ie requests ") * 1 ie9 = ieversion === 5.9 IE8 = ieversion === 5.8 IE7 = ieversion === 5.7 IE6 = ieversion === 5.6 ie5 = ieversion === 5.5 // https://developer.mozilla.org/En/Windows_Media_in_Netscape netscape = !! Window. geckoactivexobject gecko = !! Window. Netscape // includes Firefox = !! Window. Components Firefox = !! Window. updatecommands safari = !! (Navigator. Vendor & navigator. Vendor. Match (/Apple/) Safari = Window. opendatabase &&! Window. Chrome; chrome = !! (Window. Chrome & window. Google) opera = !! Window. Opera; // ao you 2 3 Maxthon =/Maxthon/I. Test (navigator. useragent) // 360 security browser is360se =/360se/I. Test (navigator. useragent)
// 2010.6.4 setTimeout (function () {// the setTimeout of FF always has a surplus parameter 0 var isff = !! Arguments. length; alert (isff)}, 0 );
// Determine IE version 2010.10.1 Ie = (function (undefined) {var v = 3, DIV = Document. createelement ('div '); While (Div. innerhtml ='
', Div. getelementsbytagname (' I ') [0]); Return v> 4? V: undefined ;}());
// Determine IE version 2011.2.24 Ie = (function () {var v = 3, DIV = document. createelement ('div '), A = div. all | []; while (div. innerhtml ='
', A [0]); Return v> 4? V :! V ;}());
// Mobile phone correlation judgment 2011.9.21 isiphone =/iPhone/I. test (navigator. useragent); isiphone4 = Window. devicepixelratio> = 2 // In the webpage, the pixel-to-point ratio is called device-pixel-ratio. The average device is 1 and the iPhone 4 is 2, some Android models are 1.5 // http://blog.webcreativepark.net/2011/01/25-173502.htmlvar UA = navigator. useragent; isandroid =/Android/I. test (UA); isblackberry =/BlackBerry/I. test (UA) iswindowphone =/iemobile/I. test (UA) isios =/iPhone | iPad | iPod/I/I. test (UA) ismobile = isandroid | isblackberry | iswindowphone | isios