因为页面提交跳转,childWin句柄在新页中不再有效,建议你用隐藏帧的方式,提交后将原页面藏起来,使窗口句柄继续有效。参考
<frameset name=myfrmset cols="*,1005">
<frame name=hide src=target.htm>
<frame name=show src=submit.htm>
</frameset>target.htm//将这个换为你的php页
<input type=button onclick=top.show.childWin.close()>submit.htm
<script>
var childWin;
function myopen()
{
childWin=window.open('process.htm','','width=250,height=40,status=yes');
top.myfrmset.cols="100%,*";
}
</script>
<form action="target.htm" target=hide>
<input type="submit" value="提交" name="submit" onclick="myopen()">
<input type=button onclick=childWin.close()>
</form>
<frameset name=myfrmset cols="*,1005">
<frame name=hide src=target.htm>
<frame name=show src=submit.htm>
</frameset>target.htm//将这个换为你的php页
<input type=button onclick=top.show.childWin.close()>submit.htm
<script>
var childWin;
function myopen()
{
childWin=window.open('process.htm','','width=250,height=40,status=yes');
top.myfrmset.cols="100%,*";
}
</script>
<form action="target.htm" target=hide>
<input type="submit" value="提交" name="submit" onclick="myopen()">
<input type=button onclick=childWin.close()>
</form>
<frameset name=myfrmset cols="*,1005">
<frame name=hide src=target.htm>
<frame name=show src=submit.htm>
</frameset>target.htm//将这个换为你的php页
<input type=button onclick=top.show.childWin.close()>submit.htm
<script>
var childWin;
function myopen()
{
childWin=window.open('process.htm','','width=250,height=40,status=yes');
top.myfrmset.cols="100%,*";
}
</script>
<form action="target.htm" target=hide>
<input type="submit" value="提交" name="submit" onclick="myopen()">
<input type=button onclick=childWin.close()>
</form>
有框架的话把新的窗口对象保存在框架里面吧:
提交前:
parent.newChildWin = childWin;
提交后:
childWin = parent.newChildWin;
<input type="submit" value="提交" name="submit" onclick="var childWin=window.open('process.htm','submit','width=250,height=40')">
</form> //注意打开新窗口的第二个参数在关闭打开的窗口childWin之前,肯定要先得到这个窗口的句柄才行:
<SCRIPT LANGUAGE="JavaScript">
<!--
childWin=window.open('','submit'); //根据submit得到刚刚窗口的句柄
childWin.close();
//-->
</SCRIPT>搞定了。
定义个process函数
当你提交的时候processID.style.visibility="visible"
这样当页面提交时间比较长的时候就显示process,提交完成后页面跳转,当然也就没有了process显示过程,我在上传文件里使用这个方法,比较好用。