javascript 实现图片加载模糊到清晰
发布网友
发布时间:2022-04-21 23:05
我来回答
共1个回答
热心网友
时间:2022-04-07 06:17
图片预加载*{ padding:0; margin:0;}#box{ width:620px; margin:0 auto;}li{ width:300px; height:300px; overflow:hidden; float:left; margin:0px 0 0 10px; background:url(1.gif) no-repeat center;}li img{display:none; width:300px; height:300px;}var arr=["http://q.chinasspp.com/uploadimg/ZoneOtherPic/2007121113466235.jpg","http://www.baobaolo.com/LackPic/lack9.jpg","http://pic8.nipic.com/20100731/31014_214108073368_2.jpg","
","http://pic.nipic.com/2007-12-07/200712713242811_2.jpg","window.onload=function(){var oBox=document.getElementById('box');var aLi=oBox.getElementsByTagName('li');var aImg=[];var aNewImg=[];for(var i=0;i{var oImg=aLi[i].getElementsByTagName('img')[0];aImg.push(oImg);var newImg=new Image();aNewImg.push(newImg);}for(var i=0;i{aNewImg[i].index=i;aNewImg[i].onload=function(){aImg[this.index].src=this.src;aImg[this.index].style.display="block";}aNewImg[i].onerror=function(){alert('图片出错');}aNewImg[i].src=arr[i];}};12345
"];window.onload=function(){var oBox=document.getElementById('box');var aLi=oBox.getElementsByTagName('li');var aImg=[];var aNewImg=[];for(var i=0;i{var oImg=aLi[i].getElementsByTagName('img')[0];aImg.push(oImg);var newImg=new Image();aNewImg.push(newImg);}for(var i=0;i{aNewImg[i].index=i;aNewImg[i].onload=function(){aImg[this.index].src=this.src;aImg[this.index].style.display="block";}aNewImg[i].onerror=function(){alert('图片出错');}aNewImg[i].src=arr[i];}};12345
"/>6 默认的第一张给一张模糊的