Re: Calling ActiveX component method from JScript



<merdza@xxxxxxxxx> wrote in message
news:1188979321.847824.291040@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am trying to call ActiveX function which resides on a client
computer from javascript or vbscript. I developed a simple Visual C++
2005 ActiveX component (ocx file) with one exported method which
returns int value. When I try to call this method from VB, everything
works fine and I get the value that method should return.

Can you be more specific VBScript or VB6? Using Late binding?


The ActiveX component was registered on the client computer with
regsvr32. I tried in two ways to call the ocx method from javascript:
- with new ActiveXObject("progID"), where the progID was found in the
registry,
- with <object classid="clsid:xxxxxxx" id="xx">, and classid was also
found in the registry.

Javascript makes the object, but cannot call the ocx method. An error
"Object doesn't support this property or method" appears on the web
page.

At Internet Explorer options I enabled all activex objects both in
Internet and intranet zone.

I looked for some kind of solution everywhere, but didn't succeed. I
am blocked at two lines of code for a week. The code of html page with
javascript follows. Thanks for any kind of help.

<HTML>
<HEAD>
<OBJECT classid="A2733628-A334-4207-83F1-F00198758EFF" id="a"></
OBJECT>
<TITLE></TITLE>
<script type='text/javascript' language='javascript'>
function callTest()
{
//first way
try{
var myobject;
myobject = new ActiveXObject("OCXTEST.ocxtestCtrl.1");
alert(myobject.test()); // activex method is called test


Try creating a standalone .js file:-

var myobject = new ActiveXObject("OCXTEST.ocxtestCtrl.1");
WScript.Echo(typeof(myobject));
WScript.Echo(myobject.test());

Does that work?



--
Anthony Jones - MVP ASP/ASP.NET


.



Relevant Pages


Loading