Call a function in ocx by using javascript

I have an ocx developed to retrieve hardware information. This ocx has a function (getInfo()) to return the obtained information in string.

I have a webpage (html) and I would like to call this getInfo() function by using javascript. However I failed and I receive a running error: Object doesn't support this property or method. It seems to me that I am not calling the function collectly. Would anyone help me please?
Function getInfo() in VB6
 
Public Function getInfo() As String
   Dim SI As SYSTEM_INFO
   Dim tmp As String, output As String  
   Call GetSystemInfo(SI)
   output = "Test Function"
   output = output & "SI.dwNumberOfProcessors: " & SI.dwNumberOfProcessors
   Select Case SI.dwProcessorType
      Case PROCESSOR_INTEL_386: tmp = "386"
      Case PROCESSOR_INTEL_486: tmp = "486"
      Case PROCESSOR_INTEL_PENTIUM: tmp = "Pentium"
      Case PROCESSOR_MIPS_R4000: tmp = "MIPS 4000"
      Case PROCESSOR_ALPHA_21064: tmp = "Alpha"
   End Select
   output = output & "SI.dwProcessorType & "" "" & tmp: " & SI.dwProcessorType & " " & tmp
   Select Case SI.wProcessorLevel
      Case PROCESSOR_LEVEL_80386: tmp = "Intel 80386"
      Case PROCESSOR_LEVEL_80486: tmp = "Intel 80486"
      Case PROCESSOR_LEVEL_PENTIUM: tmp = "Intel Pentium"
      Case PROCESSOR_LEVEL_PENTIUMII: tmp = "Intel Pentium Pro or Pentium II"
   End Select
   output = output & "SI.wProcessorLevel & "" "" & tmp: " & SI.wProcessorLevel & " " & tmp
   output = output & "SI.wProcessorRevision: " & SI.wProcessorRevision
   output = output & "GetCPUSpeed() & "" MHz"": " & GetCPUSpeed() & " MHz"
   getInfo = output
End Function
 
My html code
<html>
<HEAD>
<TITLE>myFirstOCX.CAB</TITLE>
<script type="text/javascript" FOR="window">
function fn()
{
	alert(document.all('Ctrl1').getInfo());
}
</script>
</HEAD>
<body bgcolor=lightblue LANGUAGE = VBScript>
<!--	If any of the controls on this page require licensing, you must
	create a license package file. Run LPK_TOOL.EXE to create the
	required LPK file. LPK_TOOL.EXE can be found on the ActiveX SDK,
	http://www.microsoft.com/intdev/sdk/sdk.htm. If you have the Visual
	Basic 6.0 CD, it can also be found in the \Tools\LPK_TOOL directory.
	The following is an example of the Object tag:
<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
	<PARAM NAME="LPKPath" VALUE="LPKfilename.LPK">
</OBJECT>
-->
<TABLE BORDER>
<TR>
<TD><OBJECT
CLASSID="CLSID:7BA13F4A-EA26-4753-B3B8-7DC17CE574B6"
CODEBASE="C:\Program Files\Microsoft Visual Studio\VB98\Package\myFirstOCX.ocx"
ID="Ctrl1"
name="Ctrl1">
</OBJECT>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<INPUT TYPE=BUTTON VALUE=Textbox onclick="fn()" >
</TD>
</TR>
</TABLE>
<INPUT TYPE=TEXT ID="ConnectionString" VALUE="" >
</body>
</html>

Open in new window

mishelperAsked:
Who is Participating?
 
mishelperConnect With a Mentor Author Commented:
I found that the  function within activeX object cannot be called outside the ocx file. but they can be called by set/get property of the object.

0
 
jeebukarthikeyanCommented:
hi ,

use a <% tag %> and call the function

b u d d h a
0
All Courses

From novice to tech pro — start learning today.