320个Flash广告欣赏 200个JS广告代码 580套精选PNG素材图标 151个Flash时钟代码
225实用代码片段 30个Flash全站打包下载 55个导航菜单下载 73张精品壁纸
返回列表 回复 发帖

等比缩放图片

<script language="javascript">
<!--
var flag=false;
function DrawImage(ImgD,pw,ph){
var image=new Image();
var pw1=pw
var ph1=ph
image.src=ImgD.src;
if(image.width>0 && image.height>0){
   flag=true;
   if(image.width/image.height>= pw1/ph1){
    if(image.width>pw1){
     ImgD.width=pw1;
     ImgD.height=(image.height*pw1)/image.width;
    }else{
     ImgD.width=image.width;
     ImgD.height=image.height;
    }
     ImgD.alt=image.width+"x"+image.height;
   }
else{
   if(image.height>ph1){
    ImgD.height=ph1;
    ImgD.width=(image.width*ph1)/image.height;
   }else{
    ImgD.width=image.width;
    ImgD.height=image.height;
   }
   ImgD.alt=image.width+"x"+image.height;
   }
}
}
//-->

</script>
只给了js却不说怎样应用……
不错~~~~··


但是用的时候如果图片很大就要等图片下载完才会等比缩小了
试着用了下
但是还是有点迷糊呢。。。
是不是我太笨了``
返回列表