Closed GoogleCodeExporter closed 8 years ago
Yes, you cannot script the object directly after creating it dynamically (i.e.
using
Javascript).
Creating the DOM element does not mean that the plugin was loaded &
initialized, that
an instance to handle the object was created and that the ActiveX control was
already
loaded, initialized and is already accessible.
When you try to access a method/property of the control, the plugin attempts to
resolve it using the COM component's embedded type info, the error you are
getting
means the component was not completely loaded yet, and that the member you
tried to
access is not found.
When creating objects of this plugin dynamically (I'm doing that myself in my
own web
application), you want to separate the creation of the DOM element from the
code that
attempts to access the ActiveX component. In my web app I'm doing it all under
the
OnReady document handler, just separated with enough code in between to make
sure the
component has had enough time to finish its init phase.
A more bulletproof approach is to use the onreadystatechange event handler, as
shown
in the examples in the documentation wiki and on the front page of this project.
Here's a full example with a javascript handler:
{{{
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> ActiveX Host Test Page </title>
</head>
<body>
<object
id="Control"
TYPE="application/x-itst-activex"
WIDTH="300" HEIGHT="300"
progid="ShockwaveFlash.ShockwaveFlash"
event_OnReadyStateChange="OnReady"
param_src="http://www.youtube.com/v/53RdNYwImYc">
</object>
<script type='text/javascript'>
function OnReady(state) {
console.log(state);
}
</script>
</body>
</html>
}}}
On a side note, the behavior of IE7 in this regard has changed from IE6, and
when
creating objects dynamically, you need to wait on that event as well.
As it stands, there is a solid workaround to this issue, and there's not much
to be
done in the context of this plugin that can change this behavior. I'm setting
this
issue to 'WontFix'. Feel free to contact me here or on the project's discussion
group.
Original comment by leeor.ah...@gmail.com
on 6 Feb 2009 at 1:19
Original issue reported on code.google.com by
jakob.py...@gmail.com
on 6 Feb 2009 at 12:56