自动缩略图JS


<script  language="JavaScript">  <!--  function  DrawImage(ImgD,width,height){       var  image=new  Image();       image.src=ImgD.src;       if(image.width>0  &&  image.height>0){         if(image.width/image.height>=  width/height){           if(image.width>width){               ImgD.width=width;           ImgD.height=(image.height*width)/image.width;           }else{           ImgD.width=image.width;               ImgD.height=image.height;           }           }         else{           if(image.height>height){         ImgD.height=height;           ImgD.width=(image.width*height)/image.height;                     }else{           ImgD.width=image.width;               ImgD.height=image.height;           }           }         }  }  function fiximgwin(url){var imgwin=window.open('','img','width=50,height=50')imgwin.focus()var HTML="<html>/r/n<head>/r/n<title>图片浏览</title>/r/n</head>/r/n<body leftmargin=/"0/" topmargin=/"0/">/r/n<img src=/""+url+"/" onload=/"window.resizeTo(this.width+10,this.height+50);window.moveTo((screen.width-this.width)/2,(screen.height-this.height)/2)/">/r/n</body>/r/n</html>"var doc=imgwin.documentdoc.open("text/html","replace")doc.write(HTML)doc.close()}//-->  </script>

<img src="upload/200672238047609.jpg" border="0" width="170" height="200" onload="javascript:DrawImage(this,170,200);" alt="点击看大图"  style="cursor:hand" onclick="fiximgwin('upload/200672238057609.jpg');">

posted @ 2006-08-16 14:17  spring3  阅读(181)  评论(0编辑  收藏  举报