初学者特简单的问题!回复正确马上给分
<html>
<head>
<title> New Document </title>
</head>
<body>
: <input type= "text " size= "4 " value= "10 " name= "fileSizeLimit " id= "fileSizeLimit "/> K
<input type= "file " name= "file1 " id= "file1 " size= "40 " onchange= "changeSrc(this) "/>
<img src= "about:blank " id= "fileChecker " alt= "test " height= "18 "/>
<script type= "text/javascript ">
var oFileChecker = document.getElementById( "fileChecker ");
function changeSrc(filePicker)
{
oFileChecker.src = filePicker.value;
}
oFileChecker.onreadystatechange = function ()
{
if (oFileChecker.readyState == "complete ")
{
checkSize();
}
}
function checkSize()
{
var limit = document.getElementById( "fileSizeLimit ").value * 1024;
if (oFileChecker.fileSize > limit)
{
alert( "too large ");
}
}
</script>
</body>
</html>
如果上传的图片大,他会弹出一个对话框,点击确认,如何使文本域file1的值清空
------解决方案--------------------document.getElementById( "file1 ").value = “”;
------解决方案--------------------if (oFileChecker.fileSize > limit)
{
alert( "too large ");
window.location.reload(true);
}
------解决方案--------------------文件域的value是只读的。