日期:2014-05-17 浏览次数:20565 次
<div class="pages" id="pages">
<div id="content">
<div class="upload-form">
<dl>
<dt>上传图片</dt>
<dd class="uploader"><div id="file_upload"></div></dd>
</dl>
</div>
<div class="insert-pool"></div>
<div class="example">
<img alt="" src="http://localhost:5917/UploadFiles/Images/3242035072.jpg" onload="imgResize(64,64,this)" />
</div>
</div>
</div>
<script type="text/javascript">
//图片等比例缩放
function imgResize(maxWidth, maxHeight, imgObj) {
var image = new Image();
image.src = imgObj.src;
if (image.width > 0 && image.height > 0) {
//debugger;
if (image.width / image.height >= maxWidth / maxHeight) {
if (image.width > maxWidth) {
imgObj.width = maxWidth;
imgObj.height = (image.height * maxWidth) / image.width;
} else {
imgObj.width = image.width;
imgObj.height = image.height;
}
imgObj.alt = image.width + "×" + image.height;
} else {
if (image.height > maxHeight) {
imgO