function AutoResizeImage(maxWidth,maxHeight){ var objImg = document.getElementById("operImg"); var img = 新しい画像(); img.src = objImg.src; var hRatio; var wRatio; var 比率 = 1; var w = img.width; var h = img.height; wRatio = maxWidth / w; hRatio = maxHeight / h; if (maxWidth ==0 && maxHeight==0){ 比率 = 1; }else if (maxWidth==0){// if (hRatio}else if (maxHeight==0){ if (wRatio}else if (wRatioRatio = (wRatio} if (比率w = w * 比率; h = h * 比率; } objImg.height = h; objImg.width = w; }