IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
来源:互联网 发布:微信充值琴岛通的软件 编辑:程序博客网 时间:2024/04/28 19:47
IE9创建DOM元素的方式较之前有了改变,开始严格遵循标准的实现,不允许通过直接传入一个完整html标记的方式来创建Dom元素。
document.createElement('<iframe id="yui-history-iframe" src="http://images.cnblogs.com/defaults/transparent-pixel.gif" style="position:absolute;top:0;left:0;width:1px;height:1px;visibility:hidden;"></iframe>');
解决方法:
采用标准的方式来实现:
if( $.browser.msie &&/9.0/.test(navigator.userAgent)){var iframe = document.createElement("iframe");
iframe.setAttribute("class","bgiframe");
iframe.setAttribute("frameborder","0");
iframe.setAttribute("style","display:block;position:absolute;z-index:-1;filter:Alpha(Opacity=\'0\');top:expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\');left:expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\');width:expression(this.parentNode.offsetWidth+\'px\');height:expression(this.parentNode.offsetHeight+\'px\');");
this.insertBefore( iframe,this.firstChild );
}else{
this.insertBefore( document.createElement(html),this.firstChild );
}
________________zhuanzai_____________________________________________________________
以下代码在IE8下运行通过,在IE9中出错:
document.createElement('<iframe id="yui-history-iframe" src="http://images.cnblogs.com/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", "http://images.cnblogs.com/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";
- 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
- ASP.NET获取汉字拼音的首字母
- C++中的static、const、mutable用法学习
- metasploit的WEB攻击向量
- 总结一下以前的工作中遇到的问题1
- junit测试servlet
- IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
- jQuery插件之表单验证插件validationEngine(个人感觉好用)
- Entity Framework 4.1 DbContext使用记之二——如何玩转本地实体? DbSet.Local属性的使用与实现
- poj 3628 Bookshelf 2 (0/1背包)
- Python概述:C++程序员眼中的Python
- MVC3+EF4.1学习系列(十一)----EF4.1常见的问题解决
- JSP中的EL表达式详细介绍
- 开始加大学习强度 开启新的模式
- ASP.NET MVC3: Razor中的布局