function resumeerror() { return true; } window.onerror = resumeerror; var flag=false; function drawimage(imgd,w,h){ 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*w)/image.width; }else{ imgd.width=image.width; imgd.height=image.height; } }else{ if(image.height>h){ imgd.height=h; imgd.width=(image.width*h)/image.height; }else{ imgd.width=image.width; imgd.height=image.height; } } } }