Skip to content

Instantly share code, notes, and snippets.

@OllyHodgson
Last active December 16, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OllyHodgson/5361901 to your computer and use it in GitHub Desktop.
Save OllyHodgson/5361901 to your computer and use it in GitHub Desktop.
Modernizr test for legacy IE Filters and Transitions (COMPLETELY UNTESTED!)
/*
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