使IE6 PNG透明,此方法与一般网上的不同,它没有用div之类的标签代替原来图片的标签,但是需要要道一个小道具,就是1个像素的透明gif做遮罩,原因是避免使图片出现叉叉。。
var IE6 = (window.navigator.appVersion.indexOf('MSIE 6.0')>0)
var ES_imagePath = "images/";
function ES_PNG(which){//which:图片对象
if( IE6 ){
var src = which.src
var img = new Image();
img.onload = function(){
var width = this.width
var height = this.height
which.style.width = which.width == null ? width + "px" : which.width
which.style.height = which.height == null ?height + "px" : which.height
which.src = ES_imagePath + '1px.gif' //--1个像素的透明gif
which.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')"
}
img.src = which.src;
}
}
例子:
<img src="abc.png" id="img1">
<Script>ES_PNG(document.getE)</Script>