Jquery determines the code for IE6:
if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
//Code
}
jquery determines the browser method jquery uses navigator.userAgent.indexOf to determine the browser type and does some processing. If you don’t want to use jquery, you can use it by slightly modifying the code
jquery Determine the source code of the browser (jquery1.31 as an example)
Js code:
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 browser
opera--opera browser
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 jquery, just remove the $ symbol
Quote From: http://www.zdbase.com/content/detail.aspx?OID=F50C5170-4793-4C42-966C-823D48DA5879
Use Jquery to determine the type of browser, if only to determine the type of browser It is not recommended to use this method. It is only recommended if you have already used jquery, because there is no need to load such a large class library for such a small function.
It is recommended that friends who are learning jquery study it and understand the ideas.
Mainly used method: $.browser.['browser keyword']
The code is as follows: