JS限定手机版中图片大小随分辨率自动调整的方法
实例如下:
<script type="text/javascript"> var ObjImg = jQuery(".Dy_Content img"); for (var i = 0; i < ObjImg.length; i++) { loadImage(ObjImg.eq(i)); } function loadImage(Obj) { var b_width = 320; var img = new Image(); img.src = jQuery(Obj).attr("src"); if (img.complete) { var i_width = img.width; var i_height = img.height; if (i_width > b_width) { var bx = b_width / i_width; jQuery(Obj).width(b_width); jQuery(Obj).height((bx * i_height).toFixed(0)); } return; } img.onload = function () { var i_width = this.width; var i_height = this.height; if (i_width > b_width) { var bx = b_width / i_width; jQuery(Obj).width(b_width); jQuery(Obj).height((bx * i_height).toFixed(0)); } }; }; </script>