Home > Web Front-end > JS Tutorial > body text

Another JS code for automatically shrinking images_Image special effects

WBOY
Release: 2016-05-16 19:17:05
Original
846 people have browsed it




Where the image is used: Another JS code for automatically shrinking images_Image special effects

width="180" style="max-width:90%" Note that it is best to limit it. If it is not limited, it will cause trouble when loading the image. The original size is then reduced. This process will be ugly if the image is too large. Here are the width and height. They were changed in the previous JS and the corresponding changes are made here.
<script> <BR><!-- <BR>var flag=false; <BR>function DrawImage(ImgD){ <BR>var image=new Image(); <BR>image.src=ImgD.src; <BR>if(image.width>0 && image.height>0){ <BR> flag=true; <BR> if(image.width/image.height>= 180/110){ <BR> if(image.width>180){ <BR> ImgD.width=180; <BR> ImgD.height=(image.height*110)/image.width; <BR> }else{ <BR> ImgD.width=image.width; <BR> ImgD.height=image.height; <BR> } <BR> /*ImgD.alt="Another JS code for automatically shrinking images_Image special effects" */ <BR> } <BR> else{ <BR> if(image.height>110){ <BR> ImgD.height=110; <BR> ImgD.width=(image.width*110)/image.height; <BR> }else{ <BR> ImgD.width=image.width; <BR> ImgD.height=image.height; <BR> } <BR> /*ImgD.alt="Another JS code for automatically shrinking images_Image special effects" */ <BR> } <BR>} <BR>} <BR>//--> <BR></script>
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template