| InnerHTML Issues With IE 8 |
| Written by Ben McInturff |
| Wednesday, 17 June 2009 02:15 |
|
While working with IE 8 (yes I finally bit the bullet and became part of the rising tide of IE 8 users) on Newser I was forced into the realization that IE 8 does not properly handle additions to the DOM via an innerHTML replacement such as
someDomElement.innerHTML = '<div>Some HTML Here</div>'; I actually found a few sites that have some suggestions as to how to resolve the issues:
but in my case on that site, we are already using Prototype, so there is a Prototype method update which will take a DOM element, strip the element of its children, and then adds the html content back into it properly using the DOM. It will even eval() any script within it! I keep finding more and more reasons why prototype is such a great library - and this is definitely an argument for getting to know it more. So... an element html replacement in prototype looks like this: $('someDomElement').update('<div>Some HTML Here</div>'); If you are having troubles with IE8 and its innerHTML irregularities, this article from MSDN may give you a better understanding of some of those issues. |
