Last active
December 16, 2015 02:19
-
-
Save OllyHodgson/5361901 to your computer and use it in GitHub Desktop.
Modernizr test for legacy IE Filters and Transitions (COMPLETELY UNTESTED!)
This file contains hidden or 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
/* | |
Modernizr test for legacy IE Filters and Transitions | |
I haven't tested this with Modernizr! Just adapted my solution to look like | |
https://gist.github.com/farmdawgnation/2636061 | |
Needed because Filters and Transitions can be disabled under IE's security | |
settings ("Binary and Script Behaviors" under the "ActiveX controls and | |
plug-ins" category). This is often done on corporate windows installations | |
"for security reasons". They'll fail silently (or error if you try to access | |
the element's filter collection in js). This setting also disables VML. | |
See: | |
http://paintincode.blogspot.co.uk/2012/06/css-opacity-ie-filter-binary-and-script.html | |
*/ | |
Modernizr.addTest('iefilters', function() { | |
var supportsIEfilters = false, | |
el = document.body.appendChild(document.createElement("div")), | |
probe = 0; | |
/* Try to set a filter on the div, then access the div's filters collection. | |
IE throws an error here if filters are disabled, so supportsIEfilters will | |
remain false. */ | |
try { | |
el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; | |
probe = el.filters.length; | |
supportsIEfilters = true; | |
} catch (err) { | |
/* In legacy IE, err will be "Unspecified error" if filters are disabled. | |
New browsers shouldn't have an el.filters so it'll be a reference | |
error (undefined). */ | |
/* console.log("Error: ", err); */ | |
} | |
el.parentNode.removeChild(el); | |
return supportsIEfilters; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment