Microsoft is changing the way ActiveX controls, and pretty much anything
that offers a user interface inside the web browser, can be interacted with.
This is mainly to avoid paying
patent whores
such as Eolas hundreds of millions of dollars for something they did not
invent in the first place. Normally I would moan about a change such as this,
but I applaud Microsoft for making this bold decision.
Most of the approaches offered so far involve the use of DIV tags,
innerHTML properties and a separate function for each object you want
to insert. This is a mess so together with a friend, Balazs Molnar, I have come
up with a simpler solution.
The first part of our solution is to create a single JavaScript file that
contains the following function. We'll call this file
createObject.js.
function
createObject(objectDefinition)
{
document.write(objectDefinition);
}
This function must be created in an external JavaScript file or it will not
work. This must be one of the workarounds that invalidate the patent.
We can now insert any OBJECT, EMBED or APPLET element in our HTML code in
almost the same way we did before. The only change is that we need to put a few
extra quotes and a function call in our HTML.
... other HTML
<script language="javascript">
var objectDefinition =
'<object width="425" height="350">' +
' <param name="movie" value="http://www.youtube.com/v/jkqoPkuJaMI"></param>' +
' <embed src="http://www.youtube.com/v/jkqoPkuJaMI" type="application/x-shockwave-flash" width="425" height="350"></embed>' +
'</object>';
createObject(objectDefinition);
</script>
... other HTML
The provided solution works fine in my copy of IE7b2 and is backwards compatible with IE6 as well as Firefox.
Alternative ways, all more complex than the solution offered here, are
listed below.