ajaxfileupload.js上傳檔案相容IE7及以上版本

來源:互聯網
上載者:User

標籤:bsp   協議   string   ==   text   eof   類型   func   error   

要相容IE789,要修改ajaxfileupload.js;要將此處的代碼替換掉

if(window.ActiveXObject) {      var io = document.createElement(‘<iframe id="‘ + frameId + ‘" name="‘ + frameId + ‘" />‘);       if(typeof uri== ‘boolean‘){           io.src = ‘javascript:false‘;       }       else if(typeof uri== ‘string‘){           io.src = uri;       }   }  

替換為:

var isIE = navigator.userAgent.indexOf("MSIE");var ieVersion= isIE>-1?naigator.userAgent.substring(isIE+5,isIE+6):false;if(window.ActiveXObject) {     if(ieVersion=="9" || naigator.userAgent.substring(isIE+5,isIE+7)=="10"){          var io = document.createElement(‘iframe‘);          io.id = frameId;          io.name = frameId;      }else if(ieVersion=="6" ||ieVersion=="7" || ieVersion=="8"){          var io = document.createElement(‘<iframe id="‘ + frameId + ‘" name="‘ + frameId + ‘" />‘);          if(typeof uri== ‘boolean‘){              io.src = ‘javascript:false‘;          }          else if(typeof uri== ‘string‘){              io.src = uri;          }      }  

在html中先引入jquery,再引入ajaxfileupload.js

html代碼

<input type="file" id="uploadFile" name="uploadFile"/>

js代碼

 $.ajaxfileupload({        utl:"介面",        secureuri:false,//是否需要安全性通訊協定,一般設為false        fileElementId:"uploadFile",//檔案上傳域的ID        dataType:"HTML",//傳回值類型,一般為json,但是在低版本瀏覽器下會把json看成檔案提示下載,就會沒有回呼函數,後台也要設定成"text/html"        success:function(data){            if(typeof(data.error)!="undefined"){                if(data.error!=""){                    alert(data.error);                }else{                    alert(data.msg);                }            }        },        error:function(data,status,e){            alert(e);        }    })

 

ajaxfileupload.js上傳檔案相容IE7及以上版本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.