<SCRIPT type = "text/JavaScript">
// Imgd: the IMG element of the image to be placed. This is available for parameter passing during onload.
// H: height of the IMG element, pixel
// W: IMG element width, pixel
Function autosize2 (imgd, H, W)
{
VaR image = new image ();
Image. src = imgd. SRC;
If (image. width <W & image. height {
Imgd. width = image. width;
Imgd. Height = image. height;
}
Else
{
If (W/H <= image. width/image. Height)
{
Imgd. width = W;
Imgd. Height = W * (image. Height/image. width );
}
Else
{
Imgd. width = H * (image. width/image. Height );
Imgd. Height = h;
}
}
// The picture is centered, IE8 is effective, ie9 is ineffective, Firefox is ineffective, please use table to center on the page
// Imgd. style. paddingleft = (W + 20-imgd. width)/2; // 20 indicates the sum of the distance between padding-left and padding-right.
// Imgd. style. paddingtop = (H + 20-imgd. Height)/2; // 20 indicates the sum of the distance between padding-top and padding-bottom.
}
</SCRIPT>
Call this function when loading the graph (IMG onload event)