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

 

posted @ 2018-11-05 14:35  随意滴博客  阅读(1286)  评论(0编辑  收藏  举报