JavaScript and jquery determine browser information aggregation (memo)

Source: Internet
Author: User

<script type= "Text/javascript" >
jquery determines browser information
$ (function () {
var bro=$.browser;//get browser user agent information;
var bro_msie=bro.msie;//determine whether it is IE browser, if for IE browser return: True, otherwise return: undefined;
var bro_firefox=bro.mozilla;//to determine whether it is Firefox browser, if it is the Firefox browser return: True, otherwise return: undefined;
Var bro_opera=bro.opera;//determines whether it is opera browser, if it is the Opera browser return: True, otherwise return: undefined;
The Var bro_safari=bro.safari;//determines if it is Safari browser; if it returns for Safari browser: True, otherwise return: undefined;
Determine the browser version, using the version attribute, such as to determine 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 to determine browser information
Determine if the browser is IE, Method 1
var isie=document.all? ' IE ': ' others ';//document.all value is 1 (true) under IE, while other browsers have a value of 0 (false);

Determine if 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);

Determine the version of IE
var isie6=bro.indexof ("MSIE 6.0") >0? ' IE6 ': ' other version ';//IE6 The value of 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 ';//IE7 The value of 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 ';//IE8 The value of 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 ';//IE9 The value of 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 ';//In Firefox the value of Bro.indexof ("Firefox") is greater than 1, while the value under other browsers is less than 0 (typically-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 ';//The Value of Bro.indexof ("Chrome") under Chrome 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 The value of Bro.indexof ("opera") is greater than 1, while the value under other browsers is less than 0 (typically-1);(p s: seems invalid)
var iscamino=bro.indexof ("Camino") >0? ' Camino ': ' other version ';//Camino The value of Bro.indexof ("Camino") 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 the value under other browsers is less than 0 (typically-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
Plugin (array): Navigator.plugins
User agent: Navigator.useragent
</script>

JavaScript and jquery determine browser information aggregation (memo)

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.