var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽?允许的高?
    var image=new Image();
    image.src=ImgD.src;
    // 传入的参数均为正?
    if(image.width>0 && image.height>0){
    // 设置标记?
    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=iwidth;  
            //ImgD.height=image.height;
        }  
    }
    // 如果高大于宽
    else
    {
        if(image.height>iheight)
        {
            ImgD.height=iheight;
            //ImgD.width=(image.width*iheight)/image.height;        
        }
        else
        {
            ImgD.height=iheight;
            //ImgD.width=image.width;  
            //ImgD.height=image.height;
        }    
        }
    }
    ImgD.alt="点击查看图片实际大小"
     ImgD.style.display="block"
} 
