In jquery, the navigator. userAgent. indexOf is used to determine the browser type and perform some processing. If you do not want to use jquery, you can use it if you change the code slightly.
Jquery judges IE6 code:
The Code is as follows:
If ($. browser. msie & ($. browser. version = "6.0 ")&&! $. Support. style ){
// Code
}
Jquery browser Judgment Method
In jquery, the navigator. userAgent. indexOf is used to determine the browser type and perform some processing. If you do not want to use jquery, you can use it if you change the code slightly.
Jquery determines the source code of the browser (jquery1.31 is used as an example)
Js Code:
The Code is as follows:
Var userAgent = navigator. userAgent. toLowerCase ();
// Figure out what browser is being used
JQuery. browser = {
Version: (userAgent. match (/. + (? : Rv | it | ra | ie) [\/:] ([\ d.] +)/) | [0, '0']) [1],
Safari:/webkit/. test (userAgent ),
Opera:/opera/. test (userAgent ),
Msie:/msie/. test (userAgent )&&! /Opera/. test (userAgent ),
Mozilla:/mozilla/. test (userAgent )&&! /(Compatible | webkit)/. test (userAgent)
};
Version --- browser version
Msie ---- IE browser (Microsoft Internet Explorer)
Mozilla-Firefox
Opera-operabrowser
Js Code:
Var userAgent = navigator. userAgent. toLowerCase ();
Browser = {
Version: (userAgent. match (/. + (? : Rv | it | ra | ie) [\/:] ([\ d.] +)/) | [0, '0']) [1],
Safari:/webkit/. test (userAgent ),
Opera:/opera/. test (userAgent ),
Msie:/msie/. test (userAgent )&&! /Opera/. test (userAgent ),
Mozilla:/mozilla/. test (userAgent )&&! /(Compatible | webkit)/. test (userAgent)
}
The call is the same as that of jquery, except that the $ symbol is removed.
Reference from: http://www.zdbase.com/content/detail.aspx? OID = F50C5170-4793-4C42-966C-823D48DA5879
Jquery is used to determine the type of the browser. If this method is used only to determine the type of the browser, it is not recommended. It is only recommended when jquery is used, because there is no need to load such a large class library because of such a small function.
It is recommended that you learn about jquery and learn about it.
Main usage: $. browser. ['browser keyword ']
The Code is as follows:
The Code is as follows: