﻿// JScript 文件
<!--
//图片按比例缩放
var flag=false;
function DrawImage(ImgD,Height,Width)
{
    var image=new Image();
    var iwidth = Width; //定义允许图片宽度，当宽度大于这个值时等比例缩小
    var iheight = Height; //定义允许图片高度，当宽度大于这个值时等比例缩小
    var widthcount=0;
    var heightcount=0;
    image.src=ImgD.src;
    var local=window.location.href;
    //local=local.split("/");
    if(local.split("/")[2]=="localhost")
    {
        widthcount=0;
        heightcount=0;
    }
    if(image.width>iwidth || image.height>iheight)
    {
        
        flag=true;
        if(image.width/image.height >= iwidth/iheight)
        {
            if(image.width>iwidth)
            { 
                ImgD.width=iwidth;
                ImgD.height=(image.height*iwidth)/image.width;
            }
            else
            {
                ImgD.width=image.width+widthcount; 
                ImgD.height=image.height+heightcount;
            }
    //ImgD.alt=image.width+"×"+image.height;
        }
        else
        {
            if(image.height>iheight)
            { 
                ImgD.height=iheight;
                ImgD.width=(image.width*iheight)/image.height; 
            }
            else
            {
                ImgD.width=image.width+widthcount; 
                ImgD.height=image.height+heightcount;
            }
        //ImgD.alt=image.width+"×"+image.height;
        }
    }
    else
    {
        ImgD.width=image.width+widthcount; 
        ImgD.height=image.height+heightcount;
    }
} 
//调用：<img src="图片" onload="javascript:DrawImage(this)">
//-->


