<td width="760" colspan="4" class="text13" style="word-break:break-all;word-wrap:break-word;">
<pre ><bean:write name="u2adchatdisplay" property="content"/></pre>
</td>
<script language="javascript">
<!--
//xw 为图片固定宽度700
//说明:只有宽度大于700的时候才会去缩小成700,高度成比例地缩小。
function changeImg(mypic){
var xw=700;
if(mypic.width<xw){
//宽度<700并不处理
}else{
var width = mypic.width;
var height = mypic.height;
var bili = width/height;
var ww = xw ;
var hh = Math.floor(height/bili);
mypic.height = hh;
mypic.width = ww ;
}
}
//-->
</script>
<img onload="changeImg(this)" .../>
JavaScript图片宽度调整函数示例
博客展示了一段JavaScript代码,定义了一个名为changeImg的函数,用于调整图片宽度。当图片宽度大于700时,将其宽度缩小为700,高度按比例缩小。同时还包含了一段bean标签代码。
725

被折叠的 条评论
为什么被折叠?



