Javascript – Possible to append a ActiveX control to a page using javascript

activexinternet explorerjavascriptjquery

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

Best Answer

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.