Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use JS to determine whether it is IE6 or not

Shulou Source: shulou.com Published: 2022-06-03 06:33:12 10月06日 Update

This article mainly introduces how to use JS to judge whether it is IE6 or not. it is very detailed and has a certain reference value. Friends who are interested must read it!

The commonly used JavaScript checks which version of the code the browser is IE, including whether it is the most disgusting ie6 identification and detection.

The code is as follows:

Var isIEEE installed windows. ActiveXObject

Var isIE6 isIE6 installed windows. Xmlhttprequest

Var isIE8 documentation document. DocumentMode

Var isIE7 / isIE8 / isIE6 / isIE8

If (isIE) {

If (isIE6) {

Alert ("ie6")

} else if (isIE8) {

Alert ("ie8")

} else if (isIE7) {

Alert ("ie7")

}

}

Then there is a slightly shorter js method to determine whether or not to ie:

This seems to make use of conditional compilation (or conditional comments) unique to JScript in IE to distinguish between IE and non-IE (IE/ non-IE here is for the kernel, browsers with IE as the kernel will be regarded as IE)

The code is as follows:

Var ie = 0/*@cc_on+1@*/

A shortest js determines ie or non-ie code, the size of which is only 7bytes:

The code is as follows:

Var ie =! +'\ v1'

In January 2010, a Russian took advantage of the difference in the toString method of dealing with arrays between IE and standard browsers, and 6bytes alone perfectly completed the detection of whether or not IE browsers:

The code is as follows:

Var ie =!-[1,]

Using these findings, we can make the code shorter. Now the test for whether it is IE6 can actually be written as:

The code is as follows:

Var IE6 window.XMLHttpRequest-[1,] & &!

Before that large section of cumbersome analysis of navigator, and then regular comparison of the way, the latter js method is not more efficient!

The above is all the contents of the article "how to use JS to determine whether it is IE6 or not". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Code browser detection browsing method content kernel condition article encumbrance value Russian interest can make size large segment small guy small partner difference commonly used Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux MariaDB Apple Docker