HTML 中的 ActiveX
我的要求是在 html 中使用 new ActiveX()
实例化一个对象。
我使用 ATL 创建了一个 COM 组件 SimpleActiveX
。我已经为此创建了 dll SimpleActiveX.dll。为了在 html 文件中实例化这个组件,我需要注册 dll。因此,我使用命令 regsvr32 %Path of dll% 注册了 dll。 这样做之后,我尝试在 html 文件中创建组件的实例,如下所示,
var req;
req = new ActiveX("SimpleActiveX.Hello"); //Assume Hello as a class.
req.Hi(); //Assume that Hi() is a member function of Hello.
通过这样做,我无法创建 ActiveX 对象。 Html 也不会给出任何错误。我不知道我是否做错了什么,或者我错过了什么。
谁能告诉我执行上述操作的正确步骤。
我需要如何创建 dll(在本例中,我刚刚在 Visual Studio 中构建了 ATL 项目来生成 dll)?
如果我需要在 html 中创建 ActiveX 对象,我还需要对 dll 做什么?
我遇到了一个叫做 标签,我们在其中提到了 classid 和属性。我不知道是否需要在我的 html 文件中提及这一点。
提前感谢您的帮助。
My requirement is to instantiate an object using new ActiveX()
in html.
I have created a COM component SimpleActiveX
using ATL. I have created the dll SimpleActiveX.dll for the same. In order to instantiate this component in html file I need to register the dll. So I registered the dll using the command regsvr32 %Path of dll%
.
After doing so I am trying to create and instance of the component in html file as follows,
var req;
req = new ActiveX("SimpleActiveX.Hello"); //Assume Hello as a class.
req.Hi(); //Assume that Hi() is a member function of Hello.
By doing so I am unable to create the ActiveX object.
Html doesnt give any error too. I dont know whether I am doing anything wrong or am I missing anything.
Could anyone please tell me the proper steps to perform above operations.
How do I need to create the dll (Here in this case I have just build the ATL project in Visual Studio to generate the dll)?
What else do I need to do with the dll in case if I need to create an ActiveX object in html?
I had come across something called as <object> </object>
tag in html where we mention the classid and attributes. I dont know whether I need to mention this in my html file or not.
Thanks for your help in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要在 JavaScript 中实例化 ActiveX 对象,假设 dll 已正确注册,您只需使用:
不幸的是,我不知道如何使用 Visual Studio 注册 dll。
关于标签,当您想要将对象直接嵌入到 HTML 代码中时使用它,以便在文档加载时实例化该对象,而不是使用 JavaScript。
例如:
然后您可以使用以下命令访问 COM 对象
To instantiate an ActiveX object in JavaScript, assuming the dll is correctly registered, you just have to use:
Unfortunately I don't know how to register a dll using Visual Studio.
Regarding the tag, it is used when you want to embed the object directly in your HTML code, so that it will be instantiated when the document loads, instead of using JavaScript.
For example:
Then you can access the COM object with