Last active
June 11, 2024 09:46
-
-
Save oobleck/8428063 to your computer and use it in GitHub Desktop.
Modernizr tests for IE10 & IE11, since they removed conditional comments (and still haven't gotten browsers quite right)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IE10 | |
Modernizr.addTest('ie10', function() { | |
// http://stackoverflow.com/questions/9900311/how-do-i-target-only-internet-explorer-10-for-certain-situations-like-internet-e | |
'use strict'; | |
var match = (/*@cc_on!@*/false && document.documentMode === 10); | |
return match; | |
}); | |
// IE11 | |
Modernizr.addTest('ie11', function() { | |
// https://en.wikipedia.org/wiki/Internet_Explorer_11 | |
'use strict'; | |
// var ua = navigator.userAgent; | |
// var match = /Trident.*rv[\s:]11\./i.test(ua); | |
// ('msTransform' in document.body.style) | |
var match = (!!document.documentMode && | |
!document.all && | |
(!!window.matchMedia || !!window.msMatchMedia) && | |
!Modernizr.websqldatabase && | |
!Modernizr.cssreflections); | |
return match; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following addition to the IE11 check will prevent it from including Microsoft Edge browser.
return match && (window.navigator.userAgent.indexOf('Edge/') == -1)
It may be cleaner to check for features, but meanwhile, this works.