js动态加载图片核心代码

时间:2022-06-17 05:19:06
objMapHeart.src = obj.getAttribute("ItemImage");

//==============图片预加载处理=======================

        if (qp_shared.IsIE && objMapHeart.readyState != "complete") {
objMapHeart.onreadystatechange = function() {
//表明图片已经加载完毕 IE6-IE10支持该事件
if(objMapHeart.readyState == "complete" || objMapHeart.readyState == "loaded"){
//操作
}
}
}
else if(!qp_shared.IsIE && !objMapHeart.complete) {
objMapHeart.onload = function() {
//浏览器轮询不断监测img的complete属性
if(objMapHeart.complete) {
//操作
}
};
}