do you mean document.forms[0].txtWidth.value and document.forms[0].txtHeight.value???
<form>
<img name=picView>
<input type=file name=file>
<input name=txtWidth>
<input name=txtHeight>
<input type=button onclick="GetDimension()" value=get>
</form><script language="javascript">
function GetDimension()
{
if (document.forms[0].file.value == "")
return;
document.forms[0].picView.src= document.forms[0].file.value;
document.forms[0].picView.onload = function() {
document.forms[0].txtWidth.value=this.width;
document.forms[0].txtHeight.value=this.height;
}
}
</script>
<form>
<img name=picView>
<input type=file name=file>
<input name=txtWidth>
<input name=txtHeight>
<input type=button onclick="GetDimension()" value=get>
</form><script language="javascript">
function GetDimension()
{
if (document.forms[0].file.value == "")
return;
document.forms[0].picView.src= document.forms[0].file.value;
document.forms[0].picView.onload = function() {
document.forms[0].txtWidth.value=this.width;
document.forms[0].txtHeight.value=this.height;
}
}
</script>
document.forms[0].txtWidth=document.forms[0].picView.width;
document.forms[0].txtHeight=document.forms[0].picView.Height;应该是:
document.forms[0].txtWidth.value=document.forms[0].picView.width;
document.forms[0].txtHeight.value=document.forms[0].picView.Height;
不知道大侠们取得文件大小更好的办法是什么?
<img src=http://expert.csdn.net/images/csdn.gif border=0 onload="alert('width : '+ this.clientWidth + '\r\nheight : '+ this.clientHeight)">
onload="alert('filesize : '+ fileSize +' Byte\r\nwidth : '+ clientWidth + '\r\nheight : '+ clientHeight)">
我想保留小数点2位小数,该怎么写?
round(kypfos(kypfos),2)怎么不可以呢?缺少对象错误!
function mm(s)
{
var img = new Image();
img.src = s;
alert("高 = "+ img.height + "\n宽 = "+ img.width);
alert("fileSize = "+ img.fileSize +" 字节");
}
//--></SCRIPT>