IE-only "unknown runtime error" when using replaceChild

"Charles Wiltgen" <[email protected]> Tue, 30 Jan 2007 22:43:06 -0000
Newsgroups gmane.comp.web.dom.wdf
Message-ID <[email protected]>
Hello,

I'm working on Objecty, a script that makes it easy to embed video in
a page and adds other interesting, format-agnostic abilities at the
same time.  It'll be free.

This code replaces the original tag with a <div> containing a (for
example) QuickTime Movie.  It works in everything except IE.  In IE,
the Movie appears centered at the top-left corner of the window in IE.

       var oParentEl = oElement.parentNode;
       var oTempEl = document.createElement('div');
       oTempEl.innerHTML = html;
oElement.parentNode.replaceChild(oTempEl, oElement);

This seems like an obvious IE bug.  My theory is that for IE I should
split this into two steps, first inserting the <div> into the
document, then the <div> contents after that.

Unfortunately, this code also works in everything but IE, where it
gives me an "unknown runtime error".  Literally, IE just fails without
spitting out a specific error message.

       // replace original <object> _then_ insert content
       var oParentEl = oElement.parentNode;
       var oTempEl = document.createElement('div');
       oElement.parentNode.replaceChild(oTempEl, oElement);
       oTempEl.innerHTML = html;

It fails during the last line.  The same code works fine in Firefox
and Opera for Windows.

I apologize for not lurking for a bit before posting, but I'm dying to
release a beta this week, and I've banged my head on this for hours.

-- Charles