IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
来源:互联网 发布:什么软件录屏有声音 编辑:程序博客网 时间:2024/06/06 08:45
以下代码在IE8下运行通过,在IE9中出错:
document.createElement('<iframe id="yui-history-iframe" src="../../images/defaults/transparent-pixel.gif" style="position:absolute;top:0;left:0;width:1px;height:1px;visibility:hidden;"></iframe>');
错误提示:exception : SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5)
思路分析:
第一步:兼容IE9,firefox,Opera,Safari等浏览器;
var iframe = document.createElement("iframe");
iframe.setAttribute("id", "yui-history-iframe");
iframe.setAttribute("src", "../../images/defaults/transparent-pixel.gif");
iframe.setAttribute("style","position:absolute;top:0;left:0;width:1px;height:1px;visibility:hidden;");
第二步:兼容IE6-8:由于ie6-8 不能修改iframe的name属性
var oFrame = isIE ? document.createElement("<iframe name=/"" + this._FrameName + "/">") : document.createElement("iframe");
oFrame.name = "iframName";
综合解决办法:
var isIE = (document.all) ? true : false;//这里仅仅简单的对是否是IE进行判断,详细浏览器判断:请参考浏览器类型侦测
var ua = navigator.userAgent.toLowerCase().match(/msie ([/d.]+)/)[1];
if (ua == "9.0") {
isIE = false;
}
var oFrame = isIE ? document.createElement("<iframe name=/"" + this._FrameName + "/">") : document.createElement("iframe");
oFrame.name = "iframName";
相同的问题包括js对iframe、from、input等的创建上面
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- ie9上出现DOM Exception: INVALID_CHARACTER_ERR (5)
- 解决weebox的一个Bug(IE9下exception : SCRIPT5022: DOM Exception: INVALID_CHARACTER_ERR (5))
- IE9报“DOM Exception: INVALID_CHARACTER_ERR (5)”错误的原因及解决办法
- uncaught exception: INVALID_CHARACTER_ERR: DOM Exception 5
- DOM Exception: INVALID_CHARACTER_ERR错误及解决方法
- 解决BootStrap Table表格中含中文时点击导出数据无响应的问题(Uncaught INVALID_CHARACTER_ERR: DOM Exception 5)
- 解决BootStrap Table表格中含中文时点击导出数据无响应的问题(Uncaught INVALID_CHARACTER_ERR: DOM Exception 5)
- 错误"HIERARCHY_REQUEST_ERR: DOM Exception 3"
- 错误"HIERARCHY_REQUEST_ERR: DOM Exception 3"
- Android webapp Ajax exception `INVALID_STATE_ERR: DOM Exception 11`
- Uncaught Error: SECURITY_ERR: DOM Exception 18
- insertId: Error: INVALID_ACCESS_ERR: DOM Exception 15
- 修改数据库名称
- 软件设计大师离你不远(给初学者的几点建议)
- Glib相关知识
- LDD3笔记(一)
- 反射
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- 拟采取的方法
- 自定义8583模板,打包解包,使用j8583包有改动
- 使用反射清除所有挂在事件上的delegate
- 数据库设计
- F5 big-ip GTM DNS解析过程
- 谁有惊天王V17.5版本的破解版
- 覆写 javascript中的window.confirm 显示yes/no 按钮
- 解决com.sun.xml.internal.ws.streaming.XMLStreamReaderException: unexpected XML tag.