Possible to append a ActiveX control to a page using javascript?

爷,独闯天下 提交于 2020-01-02 05:47:09

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1065828/possible-to-append-a-activex-control-to-a-page-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!