file控件隱藏的處理的方法

因爲IE禁止JS調用file控件的提交,下面是一種實現方式。供大家參考。

 

<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<style type="text/css">
  .file{
  width:300px;height:80px;
  position:relative;
  } 
  .file_file{
  width:300px;
  filter:alpha(opacity=0);
  opacity:0;
  position:absolute;left:0px;top:0px;
  z-index:10;
  }
  .file_txt{
  width:240px;height:20px;
  text-align:left;
  border:1px #a8a8a8 solid;
  position:absolute;left:0px;top:0px;
  z-index:1;
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  line-height:20px;
  }
  .file_button{
  width:50px;height:22px;
  background:#a8a8a8;
  position:absolute;right:0px;top:0px;
  z-index:1;
  }
</style>
</head><body> 
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="1.php"> 
<div class='file'>
    <input type="file" class="file_file" id="file" onchange="setValue()"/>
    <input type='text' class="file_txt" id='file_txt' />
    <div class="file_button"><input type='button' id='file_txt' value="參照" /></div>
</div>
</form> 
</body>  
</html>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章