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>
解决方案 »
- 我哪里计算错了啊 .怎么点"前进"移动的位置错位了呢?
- action向jsp传值问题
- 急!!如下代码在火狐下为什么不显示? 出问题了、
- 求助,为什么下面的javascript代码,不能每个一段时间刷新时间.
- 如果想在框架里面传个值出来要怎么做呢?
- 想深入系统的学习一下javascript,哪位朋友帮忙介绍基本这方面的电子图书的下载,谢谢~
- 急救,高手帮忙,通过proxy访问jsp页面出现问题
- 一个关于javascript很小但是很有难度的问题
- setInterval 和 setTimeout 有啥不同啊
- js怎么让页面中所有控件ID开头一样全部隐藏
- 请教:怎样在另一个页面控制层的显示与隐藏??
- 在javascript中如何給文本框賦值?
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>