Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report