一种在父窗口中得知 window.open()出的子窗口关闭事件的方法(定时器实现)

发表于:2007-06-30来源:作者:点击数: 标签:
parent.htm :br br lt;HTMLgt;lt;BODYgt;br lt;Pgt;nbsp;lt;/Pgt;br lt;form name=fm_Infogt;br lt;input type=text name=txtValuegt;br lt;/formgt;br lt;script language= java scriptgt;br var timerbr var winOpenbr function IfWindowClosed() {br nbsp;
parent.htm :<br>
<br>
&lt;HTML&gt;&lt;BODY&gt;<br>
&lt;P&gt;&nbsp;&lt;/P&gt;<br>
&lt;form name=fm_Info&gt;<br>
&lt;input type=text name=txtValue&gt;<br>
&lt;/form&gt;<br>
&lt;script language=javascript&gt;<br>
var timer<br>
var winOpen<br>
function IfWindowClosed() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;if (winOpen.closed == true) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.fm_Info.txtValue.value=&quot;child closed&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;window.clearInterval(timer)<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
}<br>
&lt;/script&gt;<br>
&lt;input type=button name=btnOpen value=open&gt;<br>
<br>
&lt;script language=javascript for=btnOpen event=onclick&gt;<br>
document.fm_Info.txtValue.value=&quot;&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;winOpen=window.open(&quot;child.htm&quot;,&quot;&quot;,&quot;toolbar=no, location=no, directories=no, status=no, menubar=no&quot; )<br>
&nbsp;&nbsp;&nbsp;&nbsp;timer=window.setInterval(&quot;IfWindowClosed()&quot;,500);<br>
&lt;/script&gt;<br>
&lt;/BODY&gt;&lt;/HTML&gt;<br>
------------------<br>
There can be anything in child.htm<br>

原文转自:http://www.ltesting.net