Shortest ie Determination

Source: Internet
Author: User

In the past, the shortest ie determination was developed by virtue of the feature that IE does not support vertical tabs.

Code:

VaR Ie =! + "\ V1 ";

Only 7 bytes! See this articleArticle, 32 bytes, ehr... 9, ehr... 7 !!! To know if your browser is IE, describes how foreigners reduce IE's judgment from 32 bytes to 7 bytes step by step! Story

But this record was broken by a Russian in January 8 this year, and now it only takes 6 bytes! It makes use of the difference between IE and the standard browser in handling the tostring method of arrays. For the standard browser, if the last character in the array is a comma, The JS engine will automatically remove it.

Code:

VaR Ie =! -[1,];
VaR Ie =! -[1,];
Alert (IE );

If we judge from the Perspective of Non-ie, we can save a bit, because when we are compatible, most of the cases are IE and non-ie.

Code:

VaR notie =-[1,];
 
If (-[1,]) {
Alert ("this is not an Internet Explorer! ");
} Else {
Alert ("this is IE browser! ");
}

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.