InHTMLpage, useActiveXthe control contains three basic actions: placing the control in aHTML, download the control to the user, and install the control on the user's machine. If only forIEusers, inHTMLinserted inActiveXcontrols are relatively simple, and if bothIEand theNetscapeusers, you need to do more work. You know,HTMLfiles by text and various flags(tags)composition,ActiveXControl forIEin theHTMLthe mark in theOBJECTthe tag has several important parameter characteristics, which are:
1.ID: Provides an identity name for the control, providing a way for the HTML code to access the control.
It means giving the control a name inside the page to access the control through this name in the Web page.
2.CLASSID: The control is unique to theUUID, TellIEwhich object is loaded. If you use a control that has already been developed, it'sCLASSIDcan be called by theWin95orNTunder the applicationRegeditto find. Run the program from the Start menu, expandHKEY_CLASSES_ROOTitem, you can see the alphabetical registry and find the name of the control you want to use, for examplewclnt, when you expand, you see aCLSIDfolder, which is the control'sCLASSID.
If you are developing the control yourself with a VC , the UUID can be ODL in the ActiveX control project (Object description Library) file, locate the UUID of a particular control by viewing the control's class information comment ,For example, to locate the cmycontrol control 's UUID, you need to find the following code:
Class Information for Cmycontrol
[UUID (051c4748-1262-11d2-87c1-00A024D948FB) ,
Licensed
helpstring ("Cmycontrol control"), control]
The content in parentheses after the UUID is the uuidof the control.
this CLASSID is the equivalent of an ID card, which finds the registered control on the computer by this number.
3.CODEBASE(code base): If there is no current version of the control on the user's machine, this parameter tells the user where the browser can find the control to download and the latest version number . after the control has been modified, you can change the version number to force the user to download again.
4.PARAM: The tag is used to set the control's initial property value, which has two attributes:name and value, which is the property name and property value .
There are also some tags, such as width, which indicates the size of the control , height, and so on, and in General, the HTML of the inserted control. The code is very similar to the HTML code that inserts Java applets .
The following is an example of an HTML code embedded with an ActiveX control :
<object id= "Cmycontrol" classid= "clsid:051c4748 - 1262 - 11d2 - 87c1 - 00A024D948FB " codebase=" http://www.mysite.com.cn/ocxdir/ Mycontrol.ocx# version=1,0,0,1 " WIDTH=400 HEIGHT=200 ALIGN=center HSPACE=0 VSPACE=0 > </OBJECT>
CODEBASE Settings, if the CAB file is saved in the same directory as the WEB file, simply write its file name, i.e. codebase= " Mycontrol.ocx#version=1,0,0,1 ";# represents the version of this control, if the version is different, The client's browser will naturally download the update.
If you want the control to beNetscaperun in addition toNetscapeneed to add plug-in outside,HTMLalso add some additional tags, in the following exampleEMBEDparagraph is forNetscapeAdd the. If you useMFCDevelopmentOCXcontrol, the first time a few users are accessed in addition to downloadingOCXfile, download the appropriateMFC DLLs, download a large quantity, then the relevant files can be packaged in the server to the client self-extracting installationCABfile. After the modifiedHTMLThe code snippet is as follows:
align= "CENTER" classid= "CLSID:
7bca18c6-2178-11d2-87c1- 00A024D948FB "
Width= "height=" id= "marquee"
Codebase= "http://218.168.188.188/scadaweb/
Wclnt.cab#version=1,0,0,1 ">
EMBED align= "CENTER" classid= "Clsid:7bca18c6- 2178-11d2- 87c1-00a024d948fb "
Width= "height=" "" "id=" Marqueequot; "
Codebase= "http://218.168.188.188/scadaweb/
Wclnt.ocx#version=1,0,0,1 "
Type= "Application/oleobject" >
A summary of a netizen
Calling OCX in the JSP(Java Server Pages) can be done as follows:
First with regsvr32 D:\TestOcx.ocx command Registration, this is my ocx storage path, of course, can also directly into the ocx Store directory to register (personal habits only)
If the registration succeeds, you will be prompted to register successfully.
Need to uninstall with regsvr32 d:\testocx.ocx/u command
Two to the registry to find the OCX CLSID
Regedit Open the registry, click on the Edit menu to find the name of the OCX , you can find its CLSID and version number
Three write down the following JSP code
<script type= "Text/javascript" language= "JavaScript" >
Function Show () {
Testocx_new. Testocx ("1");
}
</script>
<object id= "Testocx_new" width= "+" height= "32"
Classid= "CLSID:8009643F-44E9-4698-A242-3548E86FB4DF"
Codebase= "<%=request.getcontextpath ()%>\testocx.ocx#version=1.0" >
</object>
<body onload= "Show ()" >
</body>
Where:ID can be arbitrarily named,CLASSID is found in the registration table CLSID,CODEBASE is the path of the OCX , the version number is also found in the registration table.
(Have debug write and do not write no difference, do not know the problem, in my program is not written)
Then it is writing method to call the OCX event, this sentence testocx_new. Testocx ("1");
Testocx_new is your ID name,testocx ("1") is the OCX The method name and the parameters you passed in.
Here are the key parts of my actual operation:
The general method of invoking the OCX control inside a Web page