JavaScript how to quickly judge IE browser (compatible with IE10 and IE11)

Source: Internet
Author: User

In many cases, we generally use navigator.useragent and regular expressions to determine the IE browser version, the following introduction to use IE browser different characteristics to determine IE browser

1 to judge IE browser and non IE browser

IE browser and non IE browser is the difference is that IE browser support activexobject, but not IE browser does not support ActiveXObject. When the IE11 browser has not yet appeared, we judge ie and non ie often write this

function Isie () {return
       window. ActiveXObject? True:false;
   }

But in the IE11, the judgment returned is false, and I tested the following code in IE11

Alert (window. ActiveXObject);
Alert (typeof window. ActiveXObject);

The result is

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/

What is this for? Clearly ActiveXObject is there, how to typeof the result is indeed undefined. Who knows the result, tell me why? For God's horse?

The official website of Microsoft said the difference of IE11 's activexobject. Http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx. But there is no explanation for the typeof. If we use the following code to detect, it's OK.

Alert ("ActiveXObject" in Window)//returns false under Ie11

This is what I don't understand. The "ActiveXObject" in Window returns True, and why did the previous decision that IE's code returned false in IE11? ask Daniel again for an explanation. Thank you for the following directly give a compatible IE11 to judge IE and non IE browser methods.

function Isie () {return
    ("ActiveXObject" in window);
 }

Note that the prerequisite is that our program code does not cover ActiveXObject, there should be no program to do so. Oh.

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.