How does JS determine whether it is an IE browser (including IE10 and IE11) _ javascript skills

Source: Internet
Author: User
This article mainly introduces how to determine whether Javascript is an IE browser (including IE10 and IE11). If you need it, you can refer to the following code copy function, ie11 does not support document either. all, it seems that the standard will become more and more standard in the future

Today, I encountered a strange problem: there is a page that I want to specify to open in IE browser. There is no problem in the VS development environment, but it is deployed on the server. Even if I open the page with IE, the prompt "only supports IE" is displayed. It's dizzy !!
Determine whether the IE browser uses window. navigator. userAgent, tracking this information, found in the development environment, identified as IE10, but access server is identified as IE11, but IE11 userAgent does not have the MSIE Mark, this is the reason.

Change the method of judging IE browser to the following.

Original Function Syntax: no longer supported for the new version of ie11

Function isIE () {if (window. navigator. userAgent. indexOf ("MSIE")> = 1) return true; else return false ;}

Ie10 and above does not support the judgment of IE browser, because ie11 does not support document. all, the following is the version of ie11 support, of course, ie6-8 is also supported

Function isIE () {// ie? If (!! Window. ActiveXObject | "ActiveXObject" in window) return true; else return false ;}

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.