我的图片大小控制怎么不起作用?

nheps 2004-02-03 04:49:44
用底下的语句控制 当图片宽大雨500时候以500显示
<img name="img1" src="1.gif" border="0" onload="if(img1.width>500) img1.width=500" onClick="window.open(img1.src)">


可是不行啊

不能控制
效果如下:

http://free.hao263.com/17/pic.asp?id=41
...全文
52 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
stefli 2004-02-03
  • 打赏
  • 举报
回复
<script language="JavaScript">
<!--
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 164/112){
if(image.width>164){
ImgD.width=164;
ImgD.height=(image.height*164)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>112){
ImgD.height=112;
ImgD.width=(image.width*112)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>

图片调用
<img src="a.gif" border="0" width="164" height="112" onload="javascript:DrawImage(this);">
nheps 2004-02-03
  • 打赏
  • 举报
回复
谢谢
比较郁闷

tweit 2004-02-03
  • 打赏
  • 举报
回复
不清楚,帮你顶顶

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧