我用的是 window.open
我是用的方法是 在子页面 写 <body onfocus="closePopup();" onload="setFocusOnLoad();" onunload= "window.opener.research();">在父页面写 全局变量 windowpop = window.open(...); 再用 research()方法判断是否 closed但是 到父页面后 closed的结果 总是false 希望有更好的方法 或者 告知原因谢谢各位大大!!!
我是用的方法是 在子页面 写 <body onfocus="closePopup();" onload="setFocusOnLoad();" onunload= "window.opener.research();">在父页面写 全局变量 windowpop = window.open(...); 再用 research()方法判断是否 closed但是 到父页面后 closed的结果 总是false 希望有更好的方法 或者 告知原因谢谢各位大大!!!
if(childWindow.closed){ldelim}
alert("aaaaa");
{rdelim}
{rdelim}这是research方法 父页面的 也就是 子页面 一旦onunload就会读到它
<!--
function refreshParent()
{
window.opener.location.reload();
window.close();
}
//-->
</SCRIPT>
<button type="submit" value="test" name="test" onclick="refreshParent()"/>
setInterval("research()",1000);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function refreshParent()
{
window.opener.location.reload();
window.close();
}
//-->
</SCRIPT>
</HEAD> <BODY onunload="refreshParent()"> </BODY>
</HTML>
我的pop页面 有登陆功能 不能用这样的写法 谢谢你的提议
你在子页面如何调用父页的方法.得到的子窗口的closed永远都是没关闭的...
在子页面中直接掉父页面的函数,永远都是在close以前
通过setInterval可以直接跳过该句,执行完close
然后再查看子页面的closed状态时就是true了根据natineprince的思路,我做了个例子,lz参考
a.htm
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>a.htm</title>
<script>
var b = window.open('b.htm');
function research(){
window.setTimeout("bb()",1000);}
function bb(){
alert(b.closed);
}
</script>
</head><body></body></html>b.htm<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>b</title>
<script>
function aaa(){
window.opener.research();
window.close();
}
</script>
</head><body onunload="aaa()"></body>
</html>
var b = 'none';
function research() {
window.location.reload();
}
function bb() {
document.body.innerHTML += b + "<br>";
if (b == 'closed') research();
}
window.onload = function() {
document.body.onclick = function() {
b = 'opened';
window.open('b.html');
};
window.setInterval(bb, 1000);
}
B:
window.onunload = function() {
window.opener.b = 'closed';
window.close();
}