delphiwebbrowser-controltwebbrowsertembeddedwb

Inserting <bgsound> in Internet Explorer design mode


I use this code to insert <bgsound> tag.

EmbeddedWB.Doc2.body.insertAdjacentHTML('afterBegin','<bgsound src="chimes.wav">');

Ignore for a second that <bgsound> is obsolete. I am working with it because in IE6 it works.

But nothing is present in the HTML source after above operation. At first I assumed something is wrong with above code until I tried this:

EmbeddedWB.Doc2.body.insertAdjacentHTML('afterBegin','<p>chimes.wav</p>');

At the above it correctly inserts <p> tag just after the <body> as it should. So why it won't insert <bgsound> then?

Also, something weird happens if I insert <audio> tag instead:

EmbeddedWB.Doc2.body.insertAdjacentHTML('afterBegin','<audio src="chimes.wav">some audio</audio>');

After this in source all I see is some audio</audio> without the opening tag.

I am beginning to wonder if the above doesn't work because I am in designer mode, is this possible cause why it won't insert <bgaudio>? Tried to insert some other tags too... for example comments also didn't work (<!-- comment -->).

Edit: Later I tried FEATURE_BROWSER_EMULATION in registry and after setting to 11001 (0x2AF9 Internet Explorer 11 mode) both <audio> and <bgsound> tags were inserted properly from edit mode. But it must be possible in older mode doesn't it?


Solution

  • After a lot of wasted time here are some things I discovered:

    I found no solution for this but at least I have some workarounds. Perhaps it helps someone in the future.