JSP JS 判断文件大小 问题
小弟最近做一个项目 要求用JS判断文件上传的大小 在IE8下的时候用html文件 可以做到页面的跳转 但是写到jsp文件的时候
就会出现“无法设置 dynsrc 属性。 拒绝访问。”的错误
请问各位大侠 应该怎样解决啊 为啥同样的代码 在html下就好用 搬到jsp就不行了呢
我用的是resin3.0 跟这个有关系么 请大侠们指导!!
--------------------编程问答-------------------- --------------------编程问答-------------------- 没用过dynsrc这个属性,它怎么是可以使IE显示一段AVI电影。它需要的值是电影文件的URL
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form id="form" name="form" method="post" action="123.html" enctype="multipart/form-data">
<input type="file" id="file" name="file" onchange="checkFileChange(document.getElementById('file'))" />
<img id = "img" style = "display:none" />
</form>
<script type="text/javascript">
function checkFileChange(obj) {
var filesize = 0;
if(navigator.userAgent.indexOf("MSIE")>0){ //if ie
var filePath = obj.value;
var image = document.getElementById("img");
image.dynsrc=filePath;
filesize=image.fileSize;
}
else // if chrome safari firefox
{
filesize = obj.files[0].fileSize;
}
if(filesize>4*1024*1024)
{
alert("对不起,您的文件大于4MB!");
return false;
}
else
{
//alert(filesize);
document.form.submit();
return true;
}
}
</script>
</body>
</html>
补充:Java , Web 开发