自动等比例缩放网页中的图片

resizeimg.js

window.onload = function() {
    for (var index = 0; index  widthRestriction) {
            document.images[index].width = widthRestriction;
            document.images[index].height = widthRestriction / rate;
        } else if (document.images[index].height > heightRestriction) {
            document.images[index].height = heightRestriction;
            document.images[index].width = heightRestriction * rate;
        }
        document.images[index].onclick = function() {window.open(this.src)};
        document.images[index].title = document.images[index].title + ' 点击在新窗口中查看原图';
    }
}
2008-01-12 15:34 113 javascript 图片 网页设计