我按照你的方法去做了。可是网页里调用时没反映啊。 源码是这样的: <HTML> <H1> Delphi 6 ActiveX Test Page </H1><p> You should see your Delphi 6 forms or controls embedded in the form below. <HR><center><P> <OBJECT id = "dd" classid="clsid:57FDE1A6-0572-4672-8DB1-75F8D2581531" codebase="http://192.168.0.59/ctvBuildupPrj.ocx#version=1,0,1,0" width=490 height=340 align=center hspace=0 vspace=0 > <PARAM NAME="ip" VALUE="192.168.0.26"> <PARAM NAME="pro" VALUE="0"> </OBJECT> <a href="#" onClock="close()">fdsf</a><script language="JavaScript"> function close() { dd.Close(); } </Script> </HTML>
你是不是要用activeform关闭ie???
不用这么麻烦的,有现成的DestroyEvent:procedure TXxxxxxxx.DestroyEvent(Sender: TObject); begin if FEvents <> nil then FEvents.OnDestroy; //这里释放即可 end;//注意,当IE刷新时,ActiveForm会被先释放(这时也会触发DestroyEvent),然后重新加载。
最简单的方法就是开一个Close方法给外面,由外面显示调用来关闭。
方法很简单啊,你用那个设计器添加一个方法就可以了(如果你不会在ActiveForm中加方法,我我。¥#¥),在方法里面做你想做的事情。
然后 在网页的关闭里面调用一下就可以了:
<body onbeforeunload="Close()">
<body onbeforeunload="Close()">
<script language="javascript">
function Close()
{
youOBJ.CloseAll();
}
</script>
<object id="youOBJ" width=100 height=200 classid="CLSID:.......后面是自动生成的不用我写了吧>
</object>
至于CloseAll方法的添加嘛。
在ACtiveForm工程中。点击View->Type Library,就可看到编辑器,
然后在你自己的接口下面,点击按钮“new method”添加方法CloseAll
然后在代码编辑器内加入代码就可以了
如果你还不明白的话,就查看一下关于ActiveForm方面的资料吧
源码是这样的:
<HTML>
<H1> Delphi 6 ActiveX Test Page </H1><p>
You should see your Delphi 6 forms or controls embedded in the form below.
<HR><center><P>
<OBJECT
id = "dd"
classid="clsid:57FDE1A6-0572-4672-8DB1-75F8D2581531"
codebase="http://192.168.0.59/ctvBuildupPrj.ocx#version=1,0,1,0"
width=490
height=340
align=center
hspace=0
vspace=0
>
<PARAM NAME="ip" VALUE="192.168.0.26">
<PARAM NAME="pro" VALUE="0">
</OBJECT>
<a href="#" onClock="close()">fdsf</a><script language="JavaScript">
function close()
{
dd.Close();
}
</Script>
</HTML>
begin
if FEvents <> nil then FEvents.OnDestroy;
//这里释放即可
end;//注意,当IE刷新时,ActiveForm会被先释放(这时也会触发DestroyEvent),然后重新加载。