Native JavaScript and jquery determine browser version and other information

Source: Internet
Author: User
This article for you in detail through jquery and native JavaScript to determine browser information include: To determine whether the browser is IE and the version of IE and so on, interested friends can refer to ha, I hope to help you copy code code as follows :




<script type= "Text/javascript" >


//jquery to Judge browser information


$ (function () {


var bro=$.browser;//get browser user agent information;


var bro_msie=bro.msie;//judge whether IE browser, if for IE browser, return: True, otherwise return: undefined;


var bro_firefox=bro.mozilla;//to determine whether it is a Firefox browser; if the Firefox browser returns: True, otherwise return: undefined;


var bro_opera=bro.opera;//to determine whether it is opera browser, if the Opera browser returns: True, otherwise return: undefined;


var bro_safari=bro.safari;//to determine if it is a safari browser; If the Safari browser returns: True, otherwise return: undefined;


//Judge browser version, use version attribute, such as judge ie;


var ie_ver=bro.version;//ie6, return "6.0", IE7 Return "7.0", IE8 return "8.0", IE9 return "9.0", etc.


});





//Native JavaScript judge browser information


//Judge whether the browser is IE, Method 1


var isie=document.all? ' IE ': ' others '///under IE document.all value is 1 (true), while other browsers have a value of 0 (false);





//Judge whether the browser is IE, Method 2


var bro=navigator.useragent;//get browser user agent information;


var isie2=bro.indexof ("MSIE") >0? ' IE ': ' others '///Under IE bro.indexof ("MSIE") value is greater than 1, while the value under other browsers is less than 0 (typically-1);





//Judge IE version


var isie6=bro.indexof ("MSIE 6.0") >0? ' IE6 ': ' other version ';//Under IE6 bro.indexof ("MSIE 6.0") is greater than 1, while the value under other browsers is less than 0 (typically-1);


var isie7=bro.indexof ("MSIE 7.0") >0? ' IE7 ': ' other version ';//Under IE7 bro.indexof ("MSIE 7.0") is greater than 1, while the value under other browsers is less than 0 (typically-1);


var isie8=bro.indexof ("MSIE 8.0") >0? ' IE7 ': ' other version ';//Under IE8 bro.indexof ("MSIE 8.0") is greater than 1, while the value under other browsers is less than 0 (typically-1);


var isie9=bro.indexof ("Msie 9.0") >0? ' IE7 ': ' other version ';//Under IE9 bro.indexof ("MSIE 9.0") is greater than 1, while the value under other browsers is less than 0 (typically-1);


var isfirefox=bro.indexof ("Firefox") >0? ' Firefox ': ' other version ';//Under Firefox bro.indexof ("Firefox") value is greater than 1, while other browsers under the value of less than 0 (generally 1);


var issafari=bro.indexof ("Safari") >0? ' Safari ': ' other version ';//Under Safari the value of Bro.indexof ("Safari") is greater than 1, while the value under other browsers is less than 0 (typically-1);


var ischrome=bro.indexof ("Chrome") >0? ' Chrome ': ' other version ';//Under Chrome Bro.indexof ("Chrome") value is greater than 1, while the value under other browsers is less than 0 (typically-1);


var isopera=bro.indexof ("Opera") >0? ' Opera ': ' other version ';//Under Opera Bro.indexof ("opera") value is greater than 1, while the value under other browsers is less than 0 (generally-1);(p s: seems invalid)


var iscamino=bro.indexof ("Camino") >0? ' Camino ': ' other version ';//Under Camino bro.indexof ("Camino") value is greater than 1, while the value under other browsers is less than 0 (typically-1);


var ismozilla=bro.indexof ("gecko/") >0? ' Gecko ': ' other version ';//under Mozilla Bro.indexof ("gecko/") value is greater than 1, while other browsers under the value of less than 0 (generally 1);


//alert (Isopera);





//js Get browser information


//Browser code name: Navigator.appcodename


Browser name: Navigator.appname


//Browser version number: Navigator.appversion


//Support for Java: navigator.javaenabled ()


//mime Type (array): Navigator.mimetypes


//System platform: Navigator.platform


//Plugins (array): Navigator.plugins


//user agent: Navigator.useragent


</script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.