<image id="img" src="1.jpg">
<script>
o = document.getElementById("img");
if(o.clientWidth>120) o.width=120;
</script>
<script>
o = document.getElementById("img");
if(o.clientWidth>120) o.width=120;
</script>
解决方案 »
- extjs CheckboxGroup根据combobox的值重新渲染items
- 怎么让一个层始终固定在网页的那个位置 ??
- javascript操作DOM导致浏览器产生回流操作
- Microsoft JScript 运行时错误: Automation 服务器不能创建对象
- 奇怪的问题
- html表单提交,jsp如何处理
- 关于循环比较的问题,总得不到想要的结果,很急,恳求大家帮忙,分不够再加
- 在用htc文件做一些特殊效果时,怎样在HTML页面中使用我在htc文件中定义的方法?
- 有谁能给我几个javascript的炸弹啊不要关不掉窗口的和点不完的确定的那种
- 哪有可以下载的JAVASCRIPT?
- 帮帮我啊,不知道错在哪里
- 高手们,进来救救我吧!!
<!--
function checkImgWidth()
{
if(document.getElementById("imgid").width>120)
{
document.getElementById("imgid").width=120;
}
else
{
document.getElementById("imgid").width=document.getElementById("imgid").width
}
}
//-->
</script>
<SCRIPT language=JavaScript>
//图片控制函数,myImg参数永远为this,maxWidth为最大宽度数值,maxHeight为最大高度数值;function reSize(myImg, maxWidth, maxHeight){ var iniPicWidth = myImg.width; var iniPicHeight = myImg.height; var iniRate = iniPicHeight/iniPicWidth; if(iniPicWidth>maxWidth || iniPicHeight>maxHeight){ var newW = maxWidth; var newH = Math.floor(newW*iniRate); if (newH>maxHeight) { var newH = maxHeight; var newW = Math.floor(newH/iniRate); } myImg.width = newW; myImg.height = newH; }}</SCRIPT>使用方法:<img src="http://www.0577.tv/images/play.gif"; border=0 onload=reSize(this,50,1000) class=img01>