请问在ASP中如何取得图片的宽、高。

bina 2003-12-22 11:47:17
我想做的程序是控制图片的长宽
if 原图片的宽>500 then
真实图片的宽=500
  真实图片的长=原图片的长*500/原图片的宽
end if
...全文
26 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bina 2003-12-22
  • 打赏
  • 举报
回复
我的图片是从数据库中循环读出来的,没有得到应得的效果。
chinesun 2003-12-22
  • 打赏
  • 举报
回复
<IMG SRC="img.gif" border=0 alt=本文附带图片 onload="javascript:if(this.width>screen.width-370)this.width=screen.width-370">
qianxuxiaozi 2003-12-22
  • 打赏
  • 举报
回复
看看下面这段代码,对你有帮助的:

图片显示控制:
<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>= 360/270){
if(image.width>360){
ImgD.width=360;
ImgD.height=(image.height*360)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>270){
ImgD.height=270;
ImgD.width=(image.width*270)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>



调用格式:
<img src="a.gif" onload="javascript:DrawImage(this);"
bina 2003-12-22
  • 打赏
  • 举报
回复
可以了。只是翻页后不稳定,有的时候可以自动缩小,有的时候有不行。不过已经可以了。结贴:)

28,407

社区成员

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

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