缩放代码: 复制代码 代码如下: 缩放代码: <BR>//图片按比例缩放 <BR>var flag = false; <BR>function DrawImage(ImgD, iwidth, iheight) { <BR>//参数(图片,允许的宽度,允许的高度) <BR>var image = new Image(); <BR>image.src = ImgD.src; <BR>if (image.width > 0 && image.height > 0) { <BR>flag = true; <BR>if (image.width / image.height >= iwidth / iheight) { <BR>if (image.width > iwidth) { <BR>ImgD.width = iwidth; <BR>ImgD.height = (image.height * iwidth) / image.width; <BR>} else { <BR>ImgD.width = image.width; <BR>ImgD.height = image.height; <BR>} <BR>ImgD.alt = image.width + "×" + image.height; <BR>} <BR>else { <BR>if (image.height > iheight) { <BR>ImgD.height = iheight; <BR>ImgD.width = (image.width * iheight) / image.height; <BR>} else { <BR>ImgD.width = image.width; <BR>ImgD.height = image.height; <BR>} <BR>ImgD.alt = image.width + "×" + image.height; <BR>} <BR>} <BR>} <BR> 页面代码: 觉得不错的发个言! 页面代码: 1. 觉得不错的发个言!