<script type="text/javascript">
function ResizeImage(_image, max_width, max_height) {
//var max_width = 300;
//var max_height = 300;
var _width = _image.width;
var _height = _image.height;
var width_ratio = _width / max_width;
var height_ratio = _height / max_height;
//alert("Width ratio:" + _width + ", Height Ratio:" + _height);
if ( width_ratio >= height_ratio && _image.width > max_width) {
_image.width = max_width;
}
else if (height_ratio > width_ratio && _image.height > max_height) {
_image.height = max_height;
}
}
</script>
--------------------------方法二--------------------------------------
HTML Image Auto Resize, HTML图片大小自动调整
.ImageStyle {
max-height:300px;
max-300px;
expression( (this.width > 300 && this.width > this.height) ? '300px': this.width+'px');
height:expression( (this.height > 300 && this.height > this.width) ? '300px': this.height+'px');
border: 0px;
vertical-align: middle;
}