After a lot of wasted time here are some things I discovered:
Internet Explorer control strips tags which it thinks are invalid when using
insertAdjacentHTML
or eveninnerHTML
. There doesn't seem to be a way (that I know of) to insert any custom HTML code which the control will not try to validate. In IE6 where I was testing it it thinks that<bgsound>
and<audio>
tags are invalid so it strips them. It should not do that for<bgsound>
but it does. Same goes for comments like<!-- comment -->
.I found no way to insert the tag using
insertAdjacentHTML
orinnerHTML
. The best I could do is to wrap the sound tag inside some other tag - if I do that, the sound does play when inserted but it is still absent from source. Finally I inserted it directly into generated HTML before saving the HTML to disk (I tagged that sound was added and before saving HTML I inserted it into HTML without relying on MSHTML).Switching to standards mode e.g. by using registry entry
FEATURE_BROWSER_EMULATION
correctly inserts tags but won't work on some versions of Internet Explorer (I believe the minimum version would be IE9 for this to work) so it is less flexible.
I found no solution for this but at least I have some workarounds. Perhaps it helps someone in the future.