RecentlySitu zhengmei-Determination of the world's shortest IEThe article shows that only 6 bytes of IE and non-ie methods are judged. ItsCodeAs follows:
<SCRIPT>
If (! + [1,]) Alert ("this is Internet Explorer ");
Else alert ("this is not an Internet Explorer ");
</SCRIPT>
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)
RecentlySitu zhengmei-Determination of the world's shortest IEThe article shows that only 6 bytes of IE and non-ie methods are judged. ItsThe Code is as follows:
<SCRIPT>
If (! + [1,]) Alert ("this is Internet Explorer ");
Else alert ("this is not an Internet Explorer ");
</SCRIPT>
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)