Commonly used JavaScript code to detect which version of IE the browser is, including whether it is the most extremely hated IE6 identification and detection. Copy code The code is as follows:var isIE=!!window.ActiveXObject; var isIE6=isIE&&!window.XMLHttpRequest; var isIE8=isIE&&!!document.documentMode; var isIE7=isIE&&!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 it is IE: Copy code The code is as follows:var ie = 0/*@cc_on+1@*/; The shortest js code to judge IE or non-IE is only 7 bytes: Copy code The code is as follows:var ie = !+'\v1'; In January 2010, a Russian took advantage of the difference between IE and standard browsers in processing array toString methods and perfectly completed the IE browser detection with only 6 bytes: Copy code The code is as follows:var ie = !-[1,]; Using these findings, we can write code that is shorter. Now, the detection of whether it is IE6 can actually be written as: Copy code The code is as follows:var ie6=!-[1,]&&!window.XMLHttpRequest; The previous long and cumbersome analysis of navigator and the regular comparison method, the following JS method is more efficient! |
<<: Detailed explanation of triangle drawing and clever application examples in CSS
>>: An article to help you understand Js inheritance and prototype chain
Table of contents Install Docker on CentOS 8 1. U...
Project Scenario Add a custom watermark to the en...
MySQL advantage: Small size, fast speed, low tota...
1. Add alternative text to your logo This has two...
Written in front In the past and in the current p...
Special statement: This article is translated bas...
1. After connecting and logging in to MySQL, firs...
In a recent project, I needed to implement the fu...
Static files Nginx is known for its high performa...
Table of contents 1. Nodes, trees, and virtual DO...
Preface Everyone knows how to run a jar package o...
Table of contents Create a table View the databas...
Table of contents 1. Object properties 1.1 Attrib...
Preface Recently, a data was operated incorrectly...
top command is the best command that everyone is ...