Home >Web Front-end >JS Tutorial >How does JS determine whether it is an IE browser (including IE10 and IE11)_javascript skills
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; }
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; }