createUploadIframe : function(id, uri) {
//create frame
var frameId = 'jUploadFrame' + id;
if (!$.browser.msie &&/9.0/.test(navigator.userAgent)) {
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;
}
} else {
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}
io.style.position = 'absolute';
io.style.top = '-1000px';
io.style.left = '-1000px';
document.body.appendChild(io);
return io;
}
ie9上出现DOM Exception: INVALID_CHARACTER_ERR (5)
百度了下发现原来是因为 IE9创建DOM元素的方式较之前有了改变,开始严格遵循标准的实现,不允许通过直接传入
所以在创建iframe对象时必须采用标准的方式来实现
标准创建的方式是
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
所以需要对浏览器进行判断
刚开始用的是window.activeObjectx的方式来判断,后来IE9也会进入到字符串拼接的方式创建DOM,后来改为 $.browser.msie && /9.0/.test(navigator.userAgent)的方式进行判断,就解决了IE9上传报错的问题。