Native javascript and jquery determine the browser version and other information

Source: Internet
Author: User

Copy codeThe Code is as follows: <script type = "text/javascript">
// Jquery determines the browser Information
$ (Function (){
Var bro = $. browser; // get the browser user proxy information;
Var bro_msie = bro. msie; // determines whether it is in IE. If it is in IE, true is returned; otherwise, undefined is returned;
Var bro_firefox = bro. mozilla; // determines whether the Firefox browser is used. If the Firefox browser is used, the return value is true; otherwise, the return value is undefined;
Var bro_opera = bro. opera; // determines whether it is an operabrowser. If it is an operabrowser, true is returned; otherwise, undefined is returned;
Var bro_safari = bro. safari; // determines whether it is a safari browser. If it is a safari browser, return: true; otherwise, return: undefined;
// Determine the browser version and use the version attribute, such as ie;
Var ie_ver = bro. version; // ie6, returns "6.0", ie7 returns "7.0", ie8 returns "8.0", ie9 returns "9.0", and so on...
});

// Native javascript determines browser Information
// Determine whether the browser is IE. method 1
Var isIE = document. all? 'Ie': 'others '; // The document. all value in IE is 1 (true), and the value in other browsers is 0 (false );

// Determine whether the browser is IE. method 2
Var bro = navigator. userAgent; // obtain the browser user proxy information;
Var isIE2 = bro. indexOf ("MSIE")> 0? 'Ie': 'others '; // in IE, the bro. indexOf ("MSIE") value is greater than 1, and in other browsers, the value is smaller than 0 (generally-1 );

// Determine the IE version
Var isIE6 = bro. indexOf ("MSIE 6.0")> 0? 'Ie6': 'Other version'; // in IE6, bro. the value of indexOf ("MSIE 6.0") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
Var isIE7 = bro. indexOf ("MSIE 7.0")> 0? 'Ie7': 'Other version'; // In IE7, bro. the value of indexOf ("MSIE 7.0") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
Var isIE8 = bro. indexOf ("MSIE 8.0")> 0? 'Ie7': 'Other version'; // In IE8, bro. the value of indexOf ("MSIE 8.0") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
Var isIE9 = bro. indexOf ("MSIE 9.0")> 0? 'Ie7': 'Other version'; // In IE9 bro. the value of indexOf ("MSIE 9.0") is greater than 1, and the value in other browsers is smaller than 0 (generally-1). So on...
Var isFirefox = bro. indexOf ("Firefox")> 0? 'Firefox ': 'Other version'; // in Firefox, bro. the value of indexOf ("Firefox") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
Var isSafari = bro. indexOf ("Safari")> 0? 'Safari ': 'Other version'; // in Safari, bro. the value of indexOf ("Safari") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
Var isChrome = bro. indexOf ("Chrome")> 0? 'Chrome': 'Other version'; // In Chrome, bro. the value of indexOf ("Chrome") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
Var isOpera = bro. indexOf ("Opera")> 0? 'Opera ': 'Other version'; // under Opera bro. the indexOf ("Opera") value is greater than 1, while the value in other browsers is smaller than 0 (generally-1); (ps: It seems to be invalid)
Var isCamino = bro. indexOf ("Camino")> 0? 'Camino ': 'Other version'; // In the Camino bro. the value of indexOf ("Camino") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
Var isMozilla = bro. indexOf ("Gecko/")> 0? 'Gecko': 'Other version'; // in Mozilla bro. the value of indexOf ("Gecko/") is greater than 1, and the value of other browsers is smaller than 0 (generally-1 );
// Alert (isOpera );

// JS to obtain browser Information
// Browser code name: navigator. appCodeName
// Browser name: navigator. appName
// Browser version: navigator. appVersion
// Java support: navigator. javaEnabled ()
// MIME type (array): navigator. mimeTypes
// System platform: navigator. platform
// Plug-in (array): navigator. plugins
// User Agent: navigator. userAgent
</Script>

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.