内容 |
<script type=text/javascript> //正文图片内容溢出处理 function redrawimage(obj) { var boxwidth = 680; // $(obj).width() - 20; $(obj + img).each(function () { var imgwidth = $(this).width(); var imgheight = $(this).height(); if (imgwidth > boxwidth) { $(this).width(boxwidth); $(this).height(boxwidth / imgwidth * imgheight); } }) $(obj + table table).each(function () { if ($(this).width() > boxwidth) { $(this).width(boxwidth); $(this).height(boxwidth / $(this).width() * $(this).height()); } }) $(obj + tr tr).each(function () { var trimg = $(this).find('img'); if (trimg.length > 1) { var trimgwidth = (boxwidth / trimg.length); trimg.each(function () { if ($(this).width() > trimgwidth) { $(this).width(trimgwidth); $(this).height(trimgwidth / $(this).width() * $(this).height()); } }); } }) } $(window).load(function () { redrawimage(.newpic);//可以是id,或者类 (要设置的范围) }); </script> |