<div class="codetitle"> <span><a style="CURSOR: pointer" data="12157" class="copybut" id="copybut12157" onclick="doCopy('code12157')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code12157"> <br><script type="text/javascript" src="js/ jquery.min.js"></script> <br><script type="text/javascript"> <br>jQuery.fn.LoadImage=function(scaling,width,height,loadpic){ <br>if(loadpic==null)loadpic="../img/loading.gif"; <br>return this.each(function(){ <br>var t=$(this); <br>var src=$(this).attr("src") <br>var img=new Image() ; <br>img.src=src; <br>//자체 축소 그림 <br>var autoScaling=function(){ <br>if(scaling){ <br>if(img.width>0 && img.height> ;0){ <br>if(img.width/img.height>=너비/높이){ <br>if(img.width>width){ <br>t.width(width) <br>t. height((img.height*width)/img.width); <br>}else{ <br>t.width(img.width) <br>t.height(img.height) <br>} 🎜>} <br>else{ <br>if(img.height>height){ <br>t.height(height) <br>t.width((img.width*height)/img.height); <br>}else{ <br>t.width(img.width); <br>t.height(img.height) <br>} <br>} <br>} <br>} <br>} <br>//处리ff下会自动读取缓存图文 <br>if(img.complete){ <br>autoScaling(); <br>return <br>} <br>$(this).attr( "src",""); <br>var loading=$("<img alt="加载中..." title="图文加载中..." src="" loadpic "" />" ); <br>t.hide(); <br>t.after(loading); <br>$(img).load(function(){ <br>autoScaling(); <br>loading.remove() ; <br>t.attr("src",this.src); <br>t.show() <br>}); <br>} <br></script> <br><div id="content"><img src="img/20120518073933709.jpg"/></div> <br><script type="text/javascript"> <br><!-- <BR>$(window).load(function(){ <BR>$('#content img').LoadImage(true, 600,500,'img/loading.gif'); <BR>}); <BR>//--> <br></script> <br><br> </div>