ie7下javascript中获取input type=file中的内容

来源:互联网 发布:深圳软件外包协会 编辑:程序博客网 时间:2024/06/10 10:09

     var file1= document.getElementById("file1").value;

 

// 判断浏览器类型,防止浏览器将文件路径设为C:/fakepath/
     var isIE = (document.all) ? true : false;
     var isIE7 = isIE && (navigator.userAgent.indexOf('MSIE 7.0') != -1);
     var isIE8 = isIE && (navigator.userAgent.indexOf('MSIE 8.0') != -1);   
     if(isIE7 || isIE8)
     {
         var file = document.getElementById("file1");
         file.select();
         file1= document.selection.createRange().text;
         document.selection.empty();
     }

原创粉丝点击