function ViewImg()
    {
       document.getElementById('preImg').src=document.getElementById('FileUpload1').value;
    }
    
       window.onload=function()
      {
      if(navigator.userAgent.indexOf("MSIE")>0)
      {
           document.getElementById('FileUpload1').attachEvent("onpropertychange",ViewImg);
      }
       if(navigator.userAgent.indexOf("Firefox")>=0)
       {
        document.getElementById('FileUpload1').addEventListener("oninput",ViewImg, false);
       
      }
    }
我想实现图片预览功能 在FF中oninput不能用 如果用change图片控件不见了  各位高手有没有好的解决方法 谢谢!
   <img alt="" src="../NewsImg/wu.jpg"  style="width:200px; height:200px" id="preImg"/>

解决方案 »

  1.   

    从来没有使用过oninput事件,楼主可以上网搜一搜
      

  2.   

    input事件是FF中的不是  oninput 不好意思搞错了 因为FF中不能用onpropertychange
      

  3.   

    oninput改成input 顶 人呢? 快 下午结帖!
      

  4.   

    document.getElementById('FileUpload1').addEventListener("onchange",ViewImg, false); 
      

  5.   

    onchange不行的 我试过了 在fireFox中不支持
      

  6.   


    window.onload=function() { 
    if(window.ActiveXObject) { 
      document.getElementById('FileUpload1').attachEvent("onchange",ViewImg); 

    else
    document.getElementById('FileUpload1').addEventListener("change",ViewImg, false); 

      

  7.   


    onchange 是可以的不过 ff 下预览图片 是很困难的不像IE 那样可以获得文件的全路径 它只能获得文件名 ,所以 想显示客户端的文件 是行不通的
      

  8.   

    顶7楼的
    IE下可以取得本地文件的路径
    但FF下不能取得本地文件路径,所以FF下失败,并非oninput的原因
    这是无法解决的