当你点击type=file的控件流就变成WIN而不WEB,怎么可能还选择时实现其实脚本呢。要么自己写一个控件来实现,要么就在右上角点那个略缩图。你的想法不能实现的。

解决方案 »

  1.   

    <!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" />
    <title>无标题文档</title>
    <script>
    function fnPreview() {
    var ele=event.srcElement;
    document.getElementById("preview").src="file:///"+ele.value;
    }
    </script>
    </head><body>
    <form action="" enctype="multipart/form-data" method="post" name="form1" id="form1">
      <table width="100%" border="1" cellspacing="1" cellpadding="3">
        <tr>
          <td><input type="file" name="file" onchange="fnPreview()" /></td>
        </tr>
        <tr>
          <td><img id="preview"/></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
      

  2.   

    楼主的意思如果是预览的意思可以用上面兄弟的代码,如果是换掉那个按钮可以使用下面的
    <input id=a size=20><input type=button value=选择文件 style="width:100;background-image:url('1.gif')" >
    <div style="position:absolute;top:15;left:-80;width:150;filter:alpha(opacity=0);" >
    <input type="file" onpropertychange="a.value=this.value" size=33></div>