谁有取图片尺寸的JS的代码?谢谢了

cime63 2004-10-08 02:53:45
谁有取图片尺寸的JS的代码?谢谢了
...全文
153 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cime63 2004-10-09
  • 打赏
  • 举报
回复
谢谢wanghr100(灰豆宝宝.net(魔幻季节)) 了,要的就是你说的这情况情况的代码,非常感谢。非常感谢
wanghr100 2004-10-08
  • 打赏
  • 举报
回复
可以用这种方式,取得上传图像的高宽 :)

图像地址<input type="file" onchange="img.src=this.value">
高<input type="text" name="h">
宽<input type="text" name="w">
<div style="position:absolute;top:;left:0;visibility:hidden">
<img id="img" onload="Show(this)">
</div>
<script language="JavaScript">
function Show(oImg)
{
document.all.h.value=oImg.height;
document.all.w.value=oImg.width;
}
</script>
是是非非 2004-10-08
  • 打赏
  • 举报
回复
好东西
正在找自动缩放的代码呢
BlueDestiny 2004-10-08
  • 打赏
  • 举报
回复
<IMG SRC=imgsrc border=0 align=center onload='javascript:alert(this.width);alert(this.height)'>
------------------------------
自动改变图片大小
<script>
<!--
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>

<a href="<%=trim(rs("picurl"))%>" target="_blank">
<img src="<%=trim(rs("imgurl"))%>" border="0" width="164" height="112" onload="javascript:DrawImage(this);">
</a>
BlueDestiny 2004-10-08
  • 打赏
  • 举报
回复
<IMG SRC=imgsrc border=0 align=center onload='javascript:alert(this.width);alert(this.height)'>


<script>
<!--
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>

<a href="<%=trim(rs("picurl"))%>" target="_blank">
<img src="<%=trim(rs("imgurl"))%>" border="0" width="164" height="112" onload="javascript:DrawImage(this);">
</a>
孟子E章 2004-10-08
  • 打赏
  • 举报
回复
<img src="" id=x>

document.all.x.width
document.all.x.height

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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