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