Javascript is the shortest way to determine if the browser is IE

Source: Internet
Author: User

Idd.chiang release Time: April 29, 2010 Category: Javascript/as

On the internet was fortunate to see the Yi people through ie and non-IE browser to vertical tab support features to make a short term:


Above out to bytes, EHR ... 9, EHR ... 7!!! To know if your browser is IE (requires FQ)

And more cattle, it is said that the Russian Hercules with a length of 6byte to the above already seemingly can not be any shorter criteria record refresh, as follows:


Made use of the differences between IE and standard browser in handling the ToString method of the array. For a standard browser, if the last character in the array identifier a comma, the JS engine automatically rejects it.

Oneself test a bit, the effect is good, recommend to everybody to see

if (!-[1,]) {     alert (' Is ie! ')}else{     

Whether this method is worth popularizing must be verified by everyone, but it is not yet the most effective method, but this trickery can be used in many agile development needs.

Javascript is the shortest way to determine if the browser is IE

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.