Front-end development engineer: not IE IE11 (reprint)

Source: Internet
Author: User

IE11 Browser Since its release last June, although it is said to have achieved good results, but according to the Baidu Research Institute of data on the browser, the domestic seems to not see its share, but the global IE11 share has exceeded IE10 and IE9 sum. Get IE11 can be in two ways: Install Win8.1 built-in IE11, from Win 7 IE9/10 upgrade, but XP in China still have more than 60% of the share, and XP the highest can only upgrade to IE8.

Front-end testing is still hovering between IE6 ~ IE10, but in the development process occasionally discovered the difference between IE11 and the public ie.

Front-end development has been divided into the browser and Internet Explorer two, in particular, the majority version of IE as a heterogeneous treatment. Microsoft's decision to turn a new leaf, IE11 into a browser that is not "IE", has the same features as other "Web browser" browsers.

Important Changes

The IE11 supports full flex capabilities (see Building a scalable layout with Flexbox), followed by the second one with no prefix CSS property names after Firefox.

supported the SPDY protocol.

The ActiveXObject object no longer exists, which causes many code failures that rely on detecting the object to sniff the browser type.

Similarly, the Boolean value of Document.all returns FALSE. Many browsers own the object but deliberately return false when turning to a Boolean value to be compatible with the countless code that used the object to determine the browser type. Now, only IE6~IE9 will return true.

The persistent MSIE in UA is deleted, and the code that relies on this to get the browser type and version number is invalidated. To determine its type and version, MSIE and Trident must be shared.

Overflow the attachevent and replace it with AddEventListener, which also destroys the code that uses this method to determine the browser type.

The xdomainrequest introduced by IE8 is removed and replaced by XMLHttpRequest, which supports cross-domain resource sharing (CORS).

Summary

Apparently IE11 's improvements have destroyed almost all of the methods used to differentiate between the web and IE browsers, making it impossible for countless existing code to get the fact that it is an IE browser. Perhaps this is the purpose of Microsoft: IE11 is no longer "IE", you do not need to judge it out.

The following is a code that uses UA to get the IE version:

/** * Get Version if it ' s a Microsoft Internet Explorer. * * @return version code,or else null if it ' s not a IE. */function getieversion () {    var ua = navigator.useragent,matches,tridentmap={' 4 ': 8, ' 5 ': 9, ' 6 ': Ten, ' 7 ': one};    matches = Ua.match (/msie (\d+)/i);    if (Matches&&matches[1])    {        //find by MSIE        return +matches[1];    }    matches = Ua.match (/trident\/(\d+)/i);    if (Matches&&matches[1])    {        //find by Trident        return tridentmap[matches[1]]| | null;    }    We did what we could    return null;}

Since UA can be faked at will, there is no proper way to ensure that a real browser environment is detected, so the code should not depend on the specific environment and version.

Copyright notice: When reproduced, please indicate the original source and author information and this statement in the form of hyperlinks.
Article Reference address: Http://www.iefans.net/qianduan-kaifa-bushi-ie11/iefans

Front-end development engineer: not IE IE11 (reprint)

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.