/*按比例生成缩略图*/ function drawimage(imgd,w,h){ var flag=false; var image=new image(); image.src=imgd.src; if(image.width>0 && image.height>0){ flag=true; if(image.width/image.height>= w/h){ if(image.width>w){ imgd.width=w; imgd.height=(image.height*h)/image.width; } else{ imgd.width=image.width; imgd.height=image.height; } imgd.alt= ""; } else{ if(image.height>h){ imgd.height=h; imgd.width=(image.width*w)/image.height; } else{ imgd.width=image.width; imgd.height=image.height; } imgd.alt=""; } } }