Home > Web Front-end > JS Tutorial > How does JS determine whether it is an IE browser (including IE10 and IE11)_javascript skills

How does JS determine whether it is an IE browser (including IE10 and IE11)_javascript skills

WBOY
Release: 2016-05-16 15:26:14
Original
1375 people have browsed it

When I was writing a code copy function today, I discovered this problem. IE11 does not support document.all. It seems that it will become more and more standard in the future

I encountered a strange problem today. There is a page, and I want to specify it to be opened with IE browser. There is no problem in the VS development environment, but when deployed to the server, even if the page is opened with IE, it still prompts "Only supports IE" , I’m so dizzy! !
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. This is the reason.

Just change the method of judging IE browser to the following.

The original function writing method: is no longer supported in the new version of ie11

function isIE(){
if (window.navigator.userAgent.indexOf("MSIE")>=1) 
return true; 
else 
return false; 
}
Copy after login

Ie10 and above do not support IE browser judgment, because IE11 no longer supports document.all, the following is the version that supports IE11, of course IE6-8 is also supported

function isIE() { //ie?
 if (!!window.ActiveXObject || "ActiveXObject" in window)
  return true;
  else
  return false;
 }
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template