As a front-end developer, I can’t avoid IE’s pitfalls. Other browsers are fine, but IE is broken. There is no support for various things. I’m convinced. Some properties and methods are not supported by all versions of IE, while some are partially supported. In the project, the main dividing line is IE8. I believe that most of the projects currently under maintenance and development support IE8 and above. So this article briefly summarizes how to determine whether the browser is IE and its version is 8.0. First of all, some properties and methods are not supported by all versions of IE, so you only need to determine whether it is IEThe following three are the methods I used in my project. If there are new methods, they will be updated. If you have other better methods, please feel free to share them~~
//Choose one function isIE(){ // It is said that Firefox will add the document.all method in the future, so it is recommended to use the other two methods if (document.all) return true; if (!!window.ActiveXObject || "ActiveXObject" in window) return true; if (window.navigator && window.navigator.msSaveOrOpenBlob) return true; } Determine if the browser is IE8 or belowAs I mentioned above, most of the projects under maintenance and development only support IE8 and above. navigator.userAgent function isIE8(){ var DEFAULT_VERSION = 8.0; var ua = navigator.userAgent.toLowerCase(); var isIE = ua.indexOf("msie")>-1; var safariVersion; if(isIE){ safariVersion = ua.match(/msie ([\d.]+)/)[1]; } if (safariVersion <= DEFAULT_VERSION ) { return true }; } If you have special requirements and need to be compatible with lower versions, then: var isIE = !!window.ActiveXObject; var isIE6 = isIE && !window.XMLHttpRequest; var isIE8 = isIE && !!document.documentMode; var isIE7 = isIE && !isIE6 && !isIE8; CSS properties not supported by IE8 and below
Methods not supported by IEBrowse PDF files online. Since IE does not have a built-in PDF reader, you can only download and view them.
The download attribute of the <a> tag is not supported, so you can create a new iframe and set its src attribute if (isIE()){ $("a").bind('click',function(){ var elemIF = document.createElement("iframe"); elemIF.src = FilePath; elemIF.style.display = "none"; document.body.appendChild(elemIF); }); } else { $("a").attr("href",FilePath).attr("download",FileName); } The above is the details of JavaScript judging whether the browser is IE. For more information about JavaScript judging browser, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: How to use Docker container to access host network
>>: Summary of Mysql slow query operations
This article mainly introduces how to specify par...
MySQL Views Simply put, a MySQL view is a shortcu...
The default ssh port number of Linux servers is g...
The element ui table does not have a built-in dra...
theme Today I will teach you how to create a circ...
<br />In general guestbooks, forums and othe...
When building a database and writing a program, i...
Table of contents 1. Check the current status of ...
Div basic layout <div class="main"&g...
1. According to the online tutorial, the installa...
1. Environmental Preparation 1.1 Basic Environmen...
1. Basics of Linux Firewall The Linux firewall sy...
1. pc-reset PC style initialization /* normalize....
Table of contents 1. Pre-analysis 1. Variable pre...
Today we will introduce several ways to use CSS t...