JS to determine whether the browser for IE browser

Source: Internet
Author: User

We know IE browser will carry MSIE this way, so that is good to judge.

The typical useragent of IE versions are as follows:

mozilla/4.0 (compatible; MSIE 10.0; Windows NT 6.0)

mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.0)

mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)

mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)

mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

mozilla/4.0 (compatible; MSIE 5.0; Windows NT)

Where the version number is the number after the MSIE.

With ActiveXObject, only IE supports the creation of ActiveX controls, so she has something that other browsers do not have, that is, the ActiveXObject function. As long as you judge the Window object exists ActiveXObject function, you can clearly determine the current browser is IE

  code is as follows copy code

(function () {
 var isie=!! Window. ActiveXObject;
 var Isie6=isie&&!window. XMLHttpRequest;
 if (Isie) {if (isIE6) {alert (' You are using a low version browser, we recommend that you use Google Chrome browser, Firefox firefox browser, or IE7 version of the browser to ensure you have better access! ');}}
}) ();

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.