简体   繁体   English

可以使用javascript将ActiveX控件附加到页面?

[英]Possible to append a ActiveX control to a page using javascript?

I'm trying to append an ActiveX control dynamically to a page using jQuery. 我正在尝试使用jQuery动态地将ActiveX控件附加到页面。 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. 我相信当包含控件的页面已完成渲染时,IE会调用ActiveX控件的OnCreate方法。 The problem is that the tag is not present on the page until after rendering is finished, so OnCreate is never called. 问题是在渲染完成之前,页面上不存在标记,因此永远不会调用OnCreate。

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? 是否可以强制IE在特定时间调用OnCreate?

The control works fine if the tag is in the html. 如果标记在html中,则控件可以正常工作。 The only time I see problems is when I add the object to the page via javascript. 我唯一看到问题的时候是通过javascript将对象添加到页面。

Update: I need to know what IE does when it encounters an 更新:我需要知道IE遇到什么时会做什么

<object>

tag on the page at render time. 在渲染时页面上的标记。 The control works fine in that context, so IE is calling something at that time. 控件在该上下文中工作正常,因此IE当时正在调用某些东西。 I need to invoke that manually after I've added the control to the page post render. 我需要在将控件添加到页面后期渲染后手动调用它。

Thanks, Pete 谢谢,皮特

You can instantiate the control in a totally cross-platform-unfriendly manner using new ActiveXObject(ProgID). 您可以使用新的ActiveXObject(ProgID)以完全跨平台不友好的方式实例化控件。 ProgID is a string of the form "appName.typeName". ProgID是“appName.typeName”形式的字符串。 eg, 例如,

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

The example will only work if excel is installed on your machine. 该示例仅在您的计算机上安装了excel时才有效。

I had a similar problem to yours today with a java applet under IE. 今天我在IE下使用java applet遇到了类似的问题。 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. 我的解决方法(我希望在页面完成渲染后放置applet)是动态创建不可见的iframe,src指向带有我的applet的简单html页面。 After loading iframe i called it's parent to notify that the applet was loaded. 加载iframe后我调用它的父级来通知applet已加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM