One way to remember that many of the sources that are used most on the Internet is:
Copy Code code as follows:
var ie = document.all ();
This is because IE browser's document has all method, and the so-called standard browser is not, so for a long time, this is a very common method.
After that, everyone started to pursue brevity, as one of the popular methods after this:
Copy Code code as follows:
var ie =! + "\V1";
This is the use of IE does not support the characteristics of vertical tabs, only 7 characters have been very shocking, but this record was a Russian earlier this year broke, people only need 6 characters can be done.
We will not discuss what this character can do for the moment, but think of it as a study, or whatever pain you say he is idle (spit ~).
Copy Code code as follows:
var ie =! -[1,];
In fact its principle is very simple, [1,] in the standard browser will return the string "1", equivalent to the call [1,].tostring,ie return "1,". However, ie and standards will be detected, so use the minus cast to the number, the standard can successfully converted to 1, 1 will be automatically converted to true in if, and IE is converted to Nan, and then automatically converted to false! View Demo.
It's simple, right? There must be a lot of people like me thinking, how could I not have thought of it? Yes, why didn't I think of it? (Laughter ~)