html 中的file文件域

1.禁止file文件域进行编辑即手动输入
2.清空input type=file里的已选路径
下面是个简单示例:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>
  <body>  
  <form method="post" action="">  
    <input type="file"  id="uploadFile" name="fileName" onkeydown="return false;" contenteditable="false"  />  
    <input type="button" value="清空" onclick="clearFileField()" />  
  </form>  
  <script type="text/javascript">  
    function clearFileField(){   
        var obj = document.getElementById("uploadFile");   
        obj.outerHTML = obj.outerHTML; //这个只在IE中可用
         obj.value=""  //这个只在FF下用
    }   
  </script>  
 </BODY>
</HTML>

你可能感兴趣的:(html,IE)