<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(img.width>0 && img.height> ;0){ <br>if(img.width/img.height>=width/height){ <br>if(img.width>width){ <br>t.width(width); height((img.height*width)/img.width); <br>t.width(img.width); <br>t.height(img.height); 🎜>} <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>//处理ff下会自动读取存图片 <br>if(img.complete){ <br>autoScaling(); <br>return <br>} <br>$(this).attr( "src",""); <br>varloading=$("<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>}); <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>