>웹 프론트엔드 >JS 튜토리얼 >이미지 scale_javascript 기술을 제어하는 ​​JS 샘플 코드

이미지 scale_javascript 기술을 제어하는 ​​JS 샘플 코드

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-05-16 17:07:251030검색

复主代码 代码如下:

<script><BR>function DrawImage(ImgD,FitWidth,FitHeight){   <BR>    var image=new Image();   <BR>    image.src=ImgD.src;   <BR>    if(image.width>0 && image.height>0){   <BR>        if(image.width/image.height>= FitWidth/FitHeight){   <BR>            if(image.width>FitWidth){   <BR>                ImgD.width=FitWidth;   <BR>                ImgD.height=(image.height*FitWidth)/image.width;   <BR>            }   <BR>            else{   <BR>               ImgD.width=image.width;   <BR>                ImgD.height=image.height;   <BR>           }   <BR>        }   <BR>        else{   <BR>            if(image.height>FitHeight){   <BR>                ImgD.height=FitHeight;   <BR>                ImgD.width=(image.width*FitHeight)/image.height;   <BR>            }   <BR>            else{   <BR>               ImgD.width=image.width;   <BR>                ImgD.height=image.height;   <BR>            }   <BR>        }   <BR>    }   <BR>}   <P></script>

调사용 방법:
复主代码 代码如下:

点击放大图文
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.