The shortest IE judgment Code _javascript skill

Source: Internet
Author: User
Code:
var ie =!+ "\v1";
Just need 7bytes! See this article, "bytes, EHR ..." 9, EHR ... 7!!! To know if your browser is IE, tell the story of how foreigners make IE decision from bytes to 7 bytes!
But the record was broken by a Russian this January 8, and now only 6 bytes! it takes advantage of the difference between IE and standard browsers in handling the array's ToString method. For a standard browser, if the last character in the array identifier a comma, the JS engine automatically strips it.
Code:
Copy Code code as follows:

var ie =!-[1,];
var ie =!-[1,];
alert (IE);

If from the angle of non ie, can save a bit, because we do compatibility, most of the situation is IE and non ie to start.
Code:
Copy Code code as follows:

var notie =-[1,];
if (-[1,]) {
Alert ("This is not IE browser!") ");
}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.