Recently, in the article about the shortest IE browser judgment code of situ zhengmei Js in the world, we can see that there are only 6 bytes of methods for judging IE and non-ie. Its Code As follows: <textarea id="runcode83828"><Br/></textarea>
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
In fact, there are many judgment methods, mostly based on the characteristics of the browser.
For example, the method for database prototype is :!! (Window. attachevent & navigator. useragent. indexof ('Opera ') ===- 1 ). It is determined by IE's support for window. attachevent to add listening events. It is not determined by IE's use of window. addeventlistener to add listening events. Navigator. useragent. indexof ('Opera ') =-1 is because the opara browser can pretend to be Ie. If !! (Window. attachevent) is true, that is, ie; otherwise, if! Window. addeventlistener is true, and can be determined as IE.
EXT is used! "1" [0], which is determined by the feature that IE cannot use array subscript to access the string. It seems that there is a problem in IE8.
In! + Before [1,] is not found, the minimum expression for determining IE is! + "\ V1". It uses the features that IE does not support vertical tabs.
In the past, there was another common method: Document. All, because the Opera Browser can pretend to be Ie. You can write it like this :!! (Document. All & navigator. useragent. indexof ('Opera ') ===- 1 ).
There are many other items, which can be easily viewed at work.
1. + [1,]
2 .! + "\ V1"
3 .!! (Window. attachevent & navigator. useragent. indexof ('Opera ') ===- 1)
4 .!! (! Window. addeventlistener & navigator. useragent. indexof ('Opera ') ===- 1)
5 .!! (Document. All & navigator. useragent. indexof ('Opera ') ===-1)