获得某一图片有大小及尺寸
<img src=http://expert.csdn.net/images/csdn.gif border=0
onload="alert('filesize : '+ fileSize +' Byte\r\nwidth : '+ clientWidth + '\r\nheight : '+ clientHeight)">
<img src=http://expert.csdn.net/images/csdn.gif border=0
onload="alert('filesize : '+ fileSize +' Byte\r\nwidth : '+ clientWidth + '\r\nheight : '+ clientHeight)">
比如:
<script>
ori_w = ?; //宽
ori_h = ?; //高
</script>
图片的地址是http://expert.csdn.net/images/csdn.gif吧!
谢谢了!
然后再取这个img的宽高,下面这个例子应该用得上:
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%" height="30">
<script>
function gigi(hh)
{
var kk
urll=hh.ftpname.value
if (urll==""){alert("请从你的硬盘中选取你的头像文件...");return false;}
kk=urll.substring(urll.length-4,urll.length)
kk=kk.toLowerCase();
if (kk!=".jpg"){
if (kk!=".gif"){
if (kk!=".bmp"){
if (kk!=".swf"){
alert("对不起,只能上传JPG,GIF,BMP,swf格式的文件")
return false;
}
}
}
}
alert("图象的尺寸:\n宽度"+tp1.width+"\n高度"+tp1.height)
return false;
}
function lll()
{
urll2=for3.ftpname.value
re=/\\/g
urll2=urll2.replace(re,'/');
tp1.src="file://"+urll2
}
</script>
<form method="POST" action="" enctype="multipart/form-data" onsubmit="return gigi(this);" name="for3">
<input type="file" name="ftpname" size="23"> <input type="submit" value="上 传" name="B1" onmouseover="lll();this.focus();">
</td></form>
</tr>
</table>
<img border="0" src="" name="tp1">
function getwidth()
{
ori_w = document.i1.clientWidth;
ori_h = document.i1.clientHeight;
}
</script>