UnitPNGfix – fix :)

As you probably would have noticed sometimes IE6 still get’s broken image links while your using the unitPNGfix from Unit Interactive. This first started to appear after their last update.
Just use the code below and make sure you fill in the right path to the clear.gif:

var clear="clear.gif" //path to clear.gif

pngfix=function() {
	var els=document.getElementsByTagName('*');var ip=/.png/i;var i=els.length;while(i-- >0){
		var el=els[i];
		var es=el.style;
		if(el.src&&el.src.match(ip)&&es.filter==''){
			es.height=el.height;
			es.width=el.width;
			es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";
			// el.src="javascript:'#define x_width 1n#define x_height 1nstatic char x_bits[]={0x00}'"; !!!THIS IS THE PROBLEM MAKER!!!
			el.src="clear.gif"; //this is the changed line that caused the error to dissapear
		}
		else{
			var elb=el.currentStyle.backgroundImage;
			if(elb.match(ip)){
				var path=elb.split('"');
				var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';
				es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";
				es.height=el.clientHeight+'px';
				es.backgroundImage='none';
				var elkids=el.getElementsByTagName('*');
				if (elkids){
					var j=elkids.length;es.position='static';
					while (j-- >0)if(!elkids[j].style.position)elkids[j].style.position="relative";
				}
			}
		}
	}
}
window.attachEvent('onload',pngfix);

Most of all thanks to Unit Interactive for making this fix!

Bookmark and Share

Drop a comment