The following HTML object represents an ActiveX control that has a property named SubSystemA:
<object id="MainObject"
CLASSID="CLSID:2C327457-D12F-4FC4-BFC2-D7C029003D07"
width="0px" height="0px"
>
<embed name="MainObject"></embed>
</object>
SubSystemA is a COM object implementing some interface with methods, properties, and events. SubSystemA's methods and properties are easily callable from Javascript, but since SubSystemA is a property of MainObject, I am not sure how to attach an event handler to SubSystemA's events.
I know of two ways to handle events fired by MainObject:
<script type="text/javascript">
function MainObject::SomeMainEvent(arg1, arg2)
{
// Event handling logic
}
</script>
and
<script type="text/javascript" for="MainObject" event="SomeMainEvent(arg1, arg2)">
// Event handling logic
</script>
But how would one handle an event for MainObject.SubSystemA?
The following HTML object represents an ActiveX control that has a property named SubSystemA:
<object id="MainObject"
CLASSID="CLSID:2C327457-D12F-4FC4-BFC2-D7C029003D07"
width="0px" height="0px"
>
<embed name="MainObject"></embed>
</object>
SubSystemA is a COM object implementing some interface with methods, properties, and events. SubSystemA's methods and properties are easily callable from Javascript, but since SubSystemA is a property of MainObject, I am not sure how to attach an event handler to SubSystemA's events.
I know of two ways to handle events fired by MainObject:
<script type="text/javascript">
function MainObject::SomeMainEvent(arg1, arg2)
{
// Event handling logic
}
</script>
and
<script type="text/javascript" for="MainObject" event="SomeMainEvent(arg1, arg2)">
// Event handling logic
</script>
But how would one handle an event for MainObject.SubSystemA?
Share Improve this question asked Jul 15, 2009 at 5:32 Brandon PaytonBrandon Payton 4183 silver badges10 bronze badges2 Answers
Reset to default 1I found that the following works:
<object id="MainObject"
CLASSID="CLSID:2C327457-D12F-4FC4-BFC2-D7C029003D07"
width="0px" height="0px"
>
<embed name="MainObject"></embed>
</object>
<script type="text/javascript">
function MainObject.SubSystemA::SomeSubSystemEvent(arg1)
{
// Event handling logic
}
</script>
and am currently looking for a way to adapt the <script for="..." event="..."> syntax, since it seems to allow later binding where the working syntax does not.
The easiest way I have found to do events on a subobject that allows javascript plient implementation of events is to implement attachEvent and detachEvent yourself; simply save the IDispatch* of the function that is passed in, and then iterate through them and call Invoke with DISPID=0 on each one.
For MainObject itself you'll probably have to use connection points, which work a bit differently.
FireBreath abstracts all of that for both IE and Firefox, including the creation of seperate COM objects. Might be worth a look