将网页和ActiveForm的OCX方在同一个路径下 网页如下: <HTML> <H1> Delphi 5 ActiveX Test Page </H1><p> You should see your Delphi 5 forms or controls embedded in the form below. <HR><center><P> <OBJECT classid="clsid:11869FE4-128E-4E73-9246-4FB2CA8D323F" id="test" name="test" codebase="/Project1.ocx#version=1,0,0,0" width=181 height=87 align=center hspace=0 vspace=0 > </OBJECT> </HTML> <script language=vbscript> function window_onload() test.hello ="hello" //.hello 是ActiveForm里的一个外露的属性 end function </script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 1</title>
<script language="JavaScript">
<!--
function Showmsg() {
document.all["txtNow"].value = Ax1.FNow;
document.all["txtDate"].value = Ax1.FDate;
document.all["txtTime"].value = Ax1.FTime; var now = new Date();
var year = now.getYear();
var month = now.getMonth()+1;
var date = now.getDate();
var datestr = year+"-"+month+"-"+date;
document.all["txtDateTime"].value = datestr;
}function SetCaption(){
Ax1.lblCaption = "SetCaption";
Ax1.FCaption = "FCaption";
} function SetParam(){
Ax1.PassParam("1111", "2222", "string", "127");
} function Clear(){
Ax1.Clear();
}function GetParam(){
var pa1;
var pa2;
Ax1.OutParam(pa1, pa2);
document.all["txtParam1"].value = pa1;
document.all["txtParam2"].value = pa2;
}
//-->
</script>
</head><body onload="Showmsg()" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#CCCCCC" rowspan="2">
<object classid="clsid:97BA702A-E192-4ADE-804C-F3B05B833ADA"
name="Ax1"
width="394"
height="256">
<param name="ButtonCaption" value="ButtonCaption">
<param name="btnCaption" value="btnCaption">
<param name="lblCaption" value="lblCaption">
<param name="FCaption" value="FCaption">
<param name="AxBorderStyle" value="0">
</object>
</td>
<td valign="top" align="center" bgcolor="#CCCC00">
<input type="text" name="txtNow" size="50">
<br>
<input type="text" name="txtDate" size="50">
<br>
<input type="text" name="txtTime" size="50">
<br>
<input type="text" name="txtDateTime" size="50">
<br>
<input type="button" name="B1" value="GetProperty" onClick="Showmsg()">
</td>
</tr>
<tr>
<td valign="top" align="center" bgcolor="#669900">
<input type="text" name="txtParam1" size="50">
<br>
<input type="text" name="txtParam2" size="50">
<br>
<input type="button" name="B2" value="GetParam" onClick="GetParam()">
</td>
</tr>
<tr align="center" bgcolor="#009999">
<td colspan="2">
<input type="button" value="SetCaption" name="B3" onClick="SetCaption()">
<input type="button" value="SetParam" name="B4" onClick="SetParam()">
<input type="button" value="Clear" name="B5" onClick="Clear()">
</td>
</tr>
</table>
</body>
</html>
网页如下:
<HTML>
<H1> Delphi 5 ActiveX Test Page </H1><p>
You should see your Delphi 5 forms or controls embedded in the form below.
<HR><center><P>
<OBJECT
classid="clsid:11869FE4-128E-4E73-9246-4FB2CA8D323F"
id="test" name="test"
codebase="/Project1.ocx#version=1,0,0,0"
width=181
height=87
align=center
hspace=0
vspace=0
>
</OBJECT>
</HTML>
<script language=vbscript>
function window_onload()
test.hello ="hello"
//.hello 是ActiveForm里的一个外露的属性
end function
</script>