Skip to content

Instantly share code, notes, and snippets.

@Demwunz
Created March 9, 2012 16:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Demwunz/2007451 to your computer and use it in GitHub Desktop.
Save Demwunz/2007451 to your computer and use it in GitHub Desktop.
JavaScript: lightweight IE6 png fix
/*@cc_on
@if (@_win32)
try {document.execCommand('BackgroundImageCache', false, true);}catch(e){}
@end
@if (@_jscript_version <= 5.6)
(function pngFix (gif, arr) {
var k = arr.length, el, es;
while (k--) {
if (el=document.getElementById(arr[k])) {
es=el.style;es.height=el.height;es.width=el.width;es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', src='"+el.src+"',sizingMethod='image')";el.src=gif;
}
}
})("/assets/images/blank.gif",['element-id1','element-id2']);
@end
@*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment