ajaxfileupload.js 兼容ie9,10


在使用ajaxfileupload.js上傳文件時,ie9和ie10會報INVALID_CHARACTER_ERR (5)的錯誤,導致無法上傳成功;

網上查了一系列處理方式:

如:

把代碼

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;  
     }  
 }  

//修改成
if(window.ActiveXObject) {  
   if(jQuery.browser.version=="9.0" || jQuery.browser.version=="10.0"){  
        var io = document.createElement('iframe');  
        io.id = frameId;  
        io.name = frameId;  
    }else if(jQuery.browser.version=="6.0" || jQuery.browser.version=="7.0" || jQuery.browser.version=="8.0"){  
        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;  
        }  
    }  
} 

 

但jq版本問題並未成功。后查到

 

 因此在createUploadIframe判斷下ie版本即可;

具體代碼如下 :

var isIE9 = '';
        //判斷是否是ie9,10
        if (navigator.userAgent.indexOf("MSIE 9.0")>0 || navigator.userAgent.indexOf("MSIE 10.0")>0) {
            isIE9 = true;
        }
        if(window.ActiveXObject && !isIE9) {
            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;
            }
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM