IE6/7/8/9中Table/Select的innerHTML不能赋值
2011-04-04 17:10
316 查看
IE6/7/8/9中Table/Select的innerHTML赋值会报错,如下
IE6/7 :
IE8 :
IE9 :
Firefox/Safari/Chrome/Opera中正常。Ext.DomHelper中使用div,把table添加到div中间接实现。
MSDN 写道
The property is read/write for all objects except the following, for which it is read-only: COL, COLGROUP, FRAMESET, HEAD, HTML, STYLE, TABLE, TBODY, TFOOT, THEAD, TITLE, TR. The property has no default value.
DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, see About Dynamic Properties.
Select元素的innerHTML也不能赋值,
但不抛异常。
相关:
http://msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx
https://developer.mozilla.org/en/dom:element.innerhtml
http://www.w3.org/TR/html5/apis-in-html-documents.html#dom-innerhtml
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>IE6/7/8/9中TABLE的innerHTML不能赋值</title> </head> <body> <script type="text/javascript"> try{ var table = document.createElement('table'); table.innerHTML = '<tr><td>Test table innerHTML</td></tr>' document.body.appendChild(table); }catch(e){ alert(e); } </script> </body> </html>
IE6/7 :
IE8 :
IE9 :
Firefox/Safari/Chrome/Opera中正常。Ext.DomHelper中使用div,把table添加到div中间接实现。
MSDN 写道
The property is read/write for all objects except the following, for which it is read-only: COL, COLGROUP, FRAMESET, HEAD, HTML, STYLE, TABLE, TBODY, TFOOT, THEAD, TITLE, TR. The property has no default value.
DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, see About Dynamic Properties.
Select元素的innerHTML也不能赋值,
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>IE6/7/8/9中Select的innerHTML不能赋值</title> </head> <body> <script type="text/javascript"> try{ var select = document.createElement("select"); select.innerHTML = '<option value="1">one</option>'; document.body.appendChild(select); }catch(e){ alert(e); } </script> </body> </html>
但不抛异常。
相关:
http://msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx
https://developer.mozilla.org/en/dom:element.innerhtml
http://www.w3.org/TR/html5/apis-in-html-documents.html#dom-innerhtml
相关文章推荐
- IE6/7/8/9中Table/Select的innerHTML不能赋值的解决方法
- IE中table的innerHTML无法赋值
- IE6-IE9中tbody的innerHTML不能赋值bug
- IE6-IE9中tbody的innerHTML不能赋值的解决方法
- IE6-IE9中tbody的innerHTML不能赋值的解决方法
- 用innerHTML给textarea的value赋值,IE下丢失换行
- ajax异步对div innerHTML赋值 ie678不兼容
- IE6-IE9中tbody的innerHTML不能赋值的解决方法
- IE中给select的innerHTML赋值时的bug
- 解决 innerHTML 在 IE6-IE9中不能赋值的bug
- IE6-IE9中tbody的innerHTML不能赋值
- IE6-9中tbody的innerHTML不能赋值bug
- IE6/IE7/IE8/IE9中tbody的innerHTML不能赋值的完美解决方案
- 警惕innerHTML赋值在IE下导致图片多次200的问题
- IE6/IE7/IE8/IE9中tbody的innerHTML不能赋值的完美解决方案
- 在IE下给元素的innerHTML赋值,出现未知运行时错误的解决办法
- 一个IE中不能取值,在FF中和Opear中都行的取input里的值
- 解决本地调试时不能通过IE直接浏览aspnet页面的办法