二樓的理解不正确,按照下面的方法就行,我的程序就是这么做的要关闭的页面上IWRecCloseInfo: TIWRectangle; comgrid0: TIWDBGrid;给comgrid0随便加上一列,给这一列写上点击事件:procedure Tmainform.comgrid0Columns0Click(ASender: TObject; const AValue: string);begin UserSession.closesessoion;end; 捕获IE关闭时的信息:procedure Tmainform.IWAppFormRender(Sender: TObject);var closestr: string;begin closestr := '<script FOR=window EVENT=onunload>if (window.event.clientY <0) ' + '{SubmitClickConfirm(''ComGrid0'',''0_close'', true, '''');window.alert(''谢谢访问预算控制系统,欢迎下次再来!'');}</script>'; IWRecCloseInfo.Text := closestr;end;在UserSessionUnit中自定义一个过程:procedure TIWUserSession.closesessoion;begin try if (WebApplication.FindComponent('mainform') as TIWContainer) <> nil then (WebApplication.FindComponent('mainform') as TIWContainer).free; except Exit; end;end;一切都OK了,试试吧,这样就行了如果关闭页是用了模板的,要在模板上加入{%IWRecCloseInfo%},反正也看不见,放哪儿都行