Skip to content

Instantly share code, notes, and snippets.

@nowri
Last active August 29, 2015 14:03
Show Gist options
  • Save nowri/6391cd2fdf292eda84a1 to your computer and use it in GitHub Desktop.
Save nowri/6391cd2fdf292eda84a1 to your computer and use it in GitHub Desktop.
// img elems
if(typeof window.addEventListener == 'undefined' && typeof document.getElementsByClassName == 'undefined') {
$('img').each(function() {
var $this = $(this),
src = $this.attr('src');
if(src.indexOf('.png') != -1) {
$this.css({
'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '", sizingMethod="scale");'
});
}
});
}
<!--[if IE 8]>
<script>
// CSS background
$(function () {
var exp = /url\(["']*(.*?)["']*\)/;
$(".pngfix").each(function (i, el) {
var $this = $(this),
src = $this.css("background-image").replace(exp, "$1");
$this.css({
backgroundImage: "none",
filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
});
});
});
</script>
<![endif]-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment