


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.

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
