Js determines the browser type and version number

Source: Internet
Author: User
Data Record: Judging the browser type in JS is probably a problem that every developer who edited the page has encountered. Among the many browser products, many brands of IE, Firefox, Opera, and Safari have different standards. Therefore, you often need to record them based on different browsers or even the same license information: judging the browser type in JS is probably a problem that every developer who edited the page has encountered. Among many browser products, IE, Firefox, Opera, Safari ........ many brands have different standards. Therefore, you often need to perform different operations based on different browsers or even different versions of the same browser. Therefore, it is very important to know the browser's judgment method. The following lists common judgment methods: 1. Determine if the browser is IE document. all? 'Ie': 'others ': the document. all value in IE is 1, and the value in other browsers is 0. navigator. userAgent. indexOf ("MSIE")> 0? 'Ie': 'others ': navigator. userAgent indicates the user agent information. Navigator. appName. indexOf ("Microsoft ")! =-1? 'Ie': 'others ': navigator. appName indicates the browser name. 2. Determine the IE version navigator. appVersion. match (/6./I) = "6 ."? 'Ie6': 'Other version': if it is known to be an IE browser, you can use this method to determine whether it is IE6; navigator. userAgent. indexOf ("MSIE 6.0")> 0? 'Ie7': 'Other version': Same as above; navigator. appVersion. match (/7./I) = "7 ."? 'Ie7': 'Other version': if it is known to be an IE browser, you can use this method to determine whether it is IE7; navigator. userAgent. indexOf ("MSIE 7.0")> 0? 'Ie7': 'Other version': Same as above; navigator. appVersion. match (/8./I) = "8 ."? 'Ie8': 'Other version': if it is known to be an IE browser, you can use this method to determine whether it is IE8; navigator. userAgent. indexOf ("MSIE 8.0")> 0? 'Ie8': 'Other version': Same as above. 3. JS: Get browser information. browser code name: navigator. appCodeName browser name: navigator. appName browser version: navigator. appVersion supports Java: navigator. javaEnabled () MIME type (array): navigator. mimeTypes System Platform: navigator. platform Plug-in (array): navigator. plugins User Agent: navigator. userAgent DEMO: Js Code
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.