


Recommended reading of js to quickly determine IE browser (compatible with IE10 and IE11)_javascript skills
Determine whether the IE browser uses window.navigator.userAgent. Track this information and find that in the development environment, it is recognized as IE10, but when accessing the server, it is recognized as IE11, but there is no MSIE mark in the userAgent of IE11. The reason is This is it.
Just change the method of judging IE browser to the following.
function isIE() { //ie? if (!!window.ActiveXObject || "ActiveXObject" in window) return true; else return false; }
Here are some sharings, you can take a look at them, very practical analysis and explanation
In many cases, we generally use navigator.userAgent and regular expressions to determine the IE browser version. Here is an introduction to using different features in IE browser to determine IE browser
1 Determine IE browser and non-IE browser
The difference between IE browser and non-IE browser is that IE browser supports ActiveXObject, but non-IE browser does not support ActiveXObject. Before the IE11 browser appeared, this was how we often judged IE and non-IE
function isIe(){ return window.ActiveXObject ? true : false; }
But in IE11, the above judgment returns false. I tested the following code in IE11 myself
alert(window.ActiveXObject);
alert(typeof window.ActiveXObject);
The result is
Why is this? Obviously ActiveXObject exists, but the result of typeof is indeed undefined. Anyone who knows the result can tell me why? For Shenma?
The official website on Microsoft explains the differences in IE11’s ActiveXObject. http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx. But the reason for typeof is not explained. It is ok if we use the following code to detect
alert("ActiveXObject" in window)//Returns false under ie11
This is what I don’t understand again. "ActiveXObject" in window returns true. Why did the code used to judge the IE browser return false in IE11? Again, I beg the experts to give me an explanation. Thank you
The following is a direct method to determine whether IE and non-IE browsers are compatible with IE11.
function isIe(){ return ("ActiveXObject" in window); }
Note that the prerequisite is not to overwrite ActiveXObject in our program code. No program should do this. hehe.
2 Determine IE6 browser
Starting from IE7, IE supports the XMLHttpRequest object, but IE6 does not support it. Based on this feature and the previous function isIe() to judge IE, we know how to judge IE6. The judgment method is as follows
function isIe6() { // ie6是不支持window.XMLHttpRequest的 return isIe() && !window.XMLHttpRequest; }
3 Determine IE7 browser
Because document mode is supported starting from IE8, it supports document.documentMode. IE7 does not support it, but IE7 supports the XMLHttpRequest object. The judgment method is as follows
function isIe7() { //只有IE8+才支持document.documentMode return isIe() && window.XMLHttpRequest && !document.documentMode; }
4 Determine IE8 browser
Starting from IE9, Microsoft has slowly moved closer to the standard. We call IE678 a non-standard browser, and IE9+ and other browsers such as chrome and firefox are called standard browsers. One of the differences between the two is. Please test the following code. What is returned
alert(-[1,]);//What is printed in IE678 is NaN, but what is printed in standard browsers is -1
Then we can judge it is an IE8 browser based on the above differences. The method is as follows
function isIe8(){ // alert(!-[1,])//->IE678返回NaN 所以!NaN为true 标准浏览器返回-1 所以!-1为false return isIe() &&!-[1,]&&document.documentMode; }
5 Determine IE9, IE10, IE11 browsers
The browser supports JSON built-in objects from IE8, and supports the strict mode of js starting from IE10. Please refer to this article for the strict mode in JShttp://www.jb51.net/article/75037 .htm
Alert(!-[1,]) under IE9+ returns false. IE9+ supports addEventListener, but the IE11 browser does not support the original event binding attachEvent unique to IE. Based on these differences, we can distinguish IE9, IE10, and IE11 browsers.
6 Determine other browsers
/****来自曾经项目中封装的公共类函数***/ //检测函数 var check = function(r) { return r.test(navigator.userAgent.toLowerCase()); }; var statics = { /** * 是否为webkit内核的浏览器 */ isWebkit : function() { return check(/webkit/); }, /** * 是否为火狐浏览器 */ isFirefox : function() { return check(/firefox/); }, /** * 是否为谷歌浏览器 */ isChrome : function() { return !statics.isOpera() && check(/chrome/); }, /** * 是否为Opera浏览器 */ isOpera : function() { return check(/opr/); }, /** * 检测是否为Safari浏览器 */ isSafari : function() { // google chrome浏览器中也包含了safari return !statics.isChrome() && !statics.isOpera() && check(/safari/); } };
How does js determine the version of IE browser including IE11
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.jb51.net/" /> <title>脚本之家</title> <script type="text/javascript"> var userAgent = navigator.userAgent, rMsie = /(msie\s|trident.*rv:)([\w.]+)/, rFirefox = /(firefox)\/([\w.]+)/, rOpera = /(opera).+version\/([\w.]+)/, rChrome = /(chrome)\/([\w.]+)/, rSafari = /version\/([\w.]+).*(safari)/; var browser; var version; var ua = userAgent.toLowerCase(); function uaMatch(ua){ var match = rMsie.exec(ua); if(match != null){ return { browser : "IE", version : match[2] || "0" }; } var match = rFirefox.exec(ua); if (match != null) { return { browser : match[1] || "", version : match[2] || "0" }; } var match = rOpera.exec(ua); if (match != null) { return { browser : match[1] || "", version : match[2] || "0" }; } var match = rChrome.exec(ua); if (match != null) { return { browser : match[1] || "", version : match[2] || "0" }; } var match = rSafari.exec(ua); if (match != null) { return { browser : match[2] || "", version : match[1] || "0" }; } if (match != null) { return { browser : "", version : "0" }; } } var browserMatch = uaMatch(userAgent.toLowerCase()); if (browserMatch.browser){ browser = browserMatch.browser; version = browserMatch.version; } document.write(browser+version); </script> </script> </head> <body> </body> </html>
The above code implements the judgment function. Here is an introduction to its implementation principle. I hope it can help friends in need.
Let’s look at a piece of code first:
navigator.userAgent
Screenshot of information under IE11:
Then use the corresponding regular expression to match. There are still big differences between IE11 and previous versions of the browser. In the previous version, this information contained msie, but it is no longer in IE11. Trident is newly added, followed by the version number of the browser. Pay special attention to this.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6
Visual web development tools