views:

310

answers:

3

I'm trying to append an ActiveX control dynamically to a page using jQuery. The append is successful; however, the control doesn't initialize when it is done this way. I believe IE calls the OnCreate method of an ActiveX control when a page that contains a control has finished rendering. The problem is that the tag is not present on the page until after rendering is finished, so OnCreate is never called.

I'm not sure if that's the problem, it's just a guess. Does anyone have experience with this? Is it possible to force IE to call OnCreate at a specific time?

The control works fine if the tag is in the html. The only time I see problems is when I add the object to the page via javascript.

Update: I need to know what IE does when it encounters an

<object>

tag on the page at render time. The control works fine in that context, so IE is calling something at that time. I need to invoke that manually after I've added the control to the page post render.

Thanks, Pete

A: 

You can instantiate the control in a totally cross-platform-unfriendly manner using new ActiveXObject(ProgID). ProgID is a string of the form "appName.typeName". e.g.,

var excel;
excel = new ActiveXObject("Excel.Application");
...

The example will only work if excel is installed on your machine.

Arnshea
Thanks, can you explain the naming here, blah.blah? I have the source code of the control, so I just need to know what to look for. Currently, all I provide is CLSID and codebase cab in an object tag.
slypete
Do you know what these are? For example, does Application in the above example implement that IDispatch interface? I have a custom ActiveX control that I need to determine these values for.
slypete
A: 

I had a similar problem to yours today with a java applet under IE. My workaround (i wanted to put the applet after page has finished rendering) was to dynamically create invisible iframe with src pointing to simple html page with my applet. After loading iframe i called it's parent to notify that the applet was loaded.

Vexatus
I cannot use an iframe since this control is being loaded into a widget framework which supports drag and drop.
slypete
A: 

I found my answer on MSDN:

http://msdn.microsoft.com/en-us/library/ms537508(VS.85).aspx

slypete
It's far more useful to actually provide the answer as well as the link.
EricLaw -MSFT-