// 图片透明
function setPng(img, w, h) {
ua = window.navigator.userAgent.toLowerCase();
if (!/msie/.test(ua))
return;
imgStyle = "display:inline-block;" + img.style.cssText;
strNewHTML = "<span style=\"width:" + w + "px; height:" + h + "px;"
+ imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
+ img.src + "', sizingMethod='scale');\"></span>";
img.outerHTML = strNewHTML;
}
图片添加onload时间,就OK
<img id="s_weather_img" src=""
onload="javascript:setPng(this, 60, 50);" style="display: none;">
获取图片URL地址,需要传递节点对象,解析出图片url地址
function getImg(obj){
var imgPng;
ua = window.navigator.userAgent.toLowerCase();
if(!/msie/.test(ua)){
imgPng=obj.find("img").attr('src');
}else{
var style=obj.find("span").attr('style');
var start=style.indexOf("'");
style=style.substring(start+1);
var end=style.indexOf("'");
imgPng=style.substring(0,end);
}
return imgPng;
}