IE & innerHTML weirdness

J

Jeremy

I'm using innerHTML as a fall-back for IE when grabbing a remote HTML
fragment via XmlHttpRequest (since IE doesn't have importNode capability).

I create an element, like this:

var container = document.createElement("div");
someElement.appendChild(container);

Then, in the callback for the XmlHttpRequest, I do this:

container.innerHTML = "test";

At this point, I.E. throws an "Unknown runtime error".

Interestingly, if I change that "div" to a "span", it works - as long as
the "test" string contains no markup ("div" fails no matter what).
Additionally, if I try setting the innerHTML of an element that was
already there when the page loaded (as opposed to created with
createElement), that also works.

Is this a documented problem, or should I give up on taking the lazy
route and just walk the DOM of the responseXML to get the HTML fragment
to go into the container? I try to avoid recursion in javascript
wherever possible, but maybe this is not such a case.

Thanks,
Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top