Multi-gravist of automatic generation of JS automatic generation
This example is demonstrated when the image is loaded, and it will often encounter a large picture that customers upload, but if the marked high and woker is displayed, due to the shape of the picture when it is displayed. Different will cause deformation, here to solve this problem with a small footprint, you can modify it more universal, such as adding the wa_setimgautosize () function, then send it in the οnlοad = event in the picture. To call the function yourself.
->
Function wa_setimgautosize ()
{
Var img = document.all.img1; // Get pictures
Var maxWidth = 200; // Set the image width limit
Var maxheight = 100; // Set the image height limit
Var heightwidth = img.offsetheight / img.offsetwidth; // Set aspect ratio
Var widthheight = img.offsetwidth / img.offsetheight; // Set a high ratio
IF (img.readystate! = "complete") Return False; / / Make sure the picture is fully loaded
IF (img.offsetwidth> maxwidth) {
Img.width = maxwidth;
Img.height = MaxWidth * HeightWidth;
}
IF (IMG.OffSetheight> maxheight) {
Img.height = maxheight;
Img.width = maxheight * widthheight;
}
}
script>
HEAD>
>>>
>
Body>
Html>