<script type="text/javascript">
var flag=false;
function DrawImage(ImgD){
    var p_w_picpath=new Image();
    var iwidth = 186;  //定义允许图片宽度
    var iheight = 126;  //定义允许图片高度
    p_w_picpath.src=ImgD.src;
    if(p_w_picpath.width>0 && p_w_picpath.height>0){
    flag=true;
    if(p_w_picpath.width/p_w_picpath.height>= iwidth/iheight){
        if(p_w_picpath.width>iwidth){ 
        ImgD.width=iwidth;
        ImgD.height=(p_w_picpath.height*iwidth)/p_w_picpath.width;
        }else{
        ImgD.width=p_w_picpath.width; 
        ImgD.height=p_w_picpath.height;
        }
        ImgD.alt=p_w_picpath.width+"×"+p_w_picpath.height;
        }
    else{
        if(p_w_picpath.height>iheight){ 
        ImgD.height=iheight;
        ImgD.width=(p_w_picpath.width*iheight)/p_w_picpath.height;       
        }else{
        ImgD.width=p_w_picpath.width; 
        ImgD.height=p_w_picpath.height;
        }
        ImgD.alt=p_w_picpath.width+"×"+p_w_picpath.height;
        }
    }
}
</script>



调用方法:
<img src="../**.JPG" style="border:none" />