Jquery determines the browser type

web front end ten thousand six hundred and fifty-seven 12 years ago (2013-08-11)

Use jquery to judge browser Syntax required: $ Browser. ['Browser keyword ']

Example of judging the syntax of each browser:

 $(function() {  if($.browser.msie) {  alert("this is msie");   else if($.browser.safari)   alert("this is safari! ");   else if($.browser.mozilla)   alert("this is mozilla! ");   else if($.browser.opera) {  alert("this is opera");   else {  alert("i don't konw! ");  }

In addition, we can also use the HTML annotation format to determine the browser type, such as in the IE6 The browser prompts the user to upgrade to achieve better display effect:

 <!--[if IE 6]>  <p>You are using IE6 to access this page. In order to achieve better display effect, please upgrade your browser version</ p>  <![endif]-->

The HTML annotation format can also use greater than, equal to, or less than operators like JQuery:

[if IE] Judge whether IE

[if! IE] Judge whether it is not IE

[if lt IE 5.5] Judge whether it is below IE5.5

[if lte IE 6] Judge whether IE6 or below

[if gt IE 5] Judge whether IE5 or above

[if gte IE 7] Judge whether IE7 or above

[if IE 7] Judge whether it is IE7

[if! (IE 7)] Judge whether it is not IE7

[if (gt IE 5)&(lt IE 7)] Judge whether IE5 is above and IE7 is below

[if (IE 6) | (IE 7)] Judge whether IE6 or IE7

 <! -- [if IE]><p>You are using IE browser</p><! [endif]-->  <! [if! IE]><p>You are not using an IE browser</ p><! [endif]> <! -- [if (IE 5)]><p>You are using IE5 browser</ p><! [endif]--> <! -- [if (gte IE 5.5)&(lt IE 7)]><p>You are using IE5.5 or IE6 browser</ p><! [endif]--> <! -- [if lt IE 5.5]><p>You are using browsers below IE5</p><! [endif]--> <! -- [if IE 7]><p>You are using IE7 browser</ p><! [endif]--> <! -- [if! (IE 7)]><p>You are not using an IE7 browser</ p><! [endif]-->  <! -- [if gte IE 7]><p>You are using IE7 or above browser</ p><! [endif]-->