注册 登录
编程论坛 JavaScript论坛

求教JS 如何刷新父页的父页?

leapceo 发布于 2008-12-11 11:16, 2798 次点击
在正常情况下,如果子页关闭的同时刷新父页用 window.opener.location.reload(); 就可以了.

现在我遇到另外一种情况:首先弹出A列表页,点击A页连接弹出B内容页,在点击B页回复按钮弹出C页并同时关闭B页了,在C页填写完回复内容按确定按钮,我可以关闭该C页而无法刷新A页,我应该用什么语句去刷新A页
9 回复
#2
zplove2008-12-11 11:24
parent.parent.location.reload();应该是父页面的父页面的
#3
leapceo2008-12-11 14:08
朋友,不行呀,我测试了,谁还有更好的办法,急呀
#4
bygg2008-12-11 14:15
window.top.location.reload();
#5
leapceo2008-12-11 14:39
谢谢楼上的热心朋友,用了你的方法,也是没反映
#6
bygg2008-12-11 15:58
你是用的什么方法调出C页面,并同时关闭B页面的?
#7
bygg2008-12-11 16:23
我试了一下,在打开C时不能关闭B,要不然找不到A...

下面是我测试的代码:

A页面
程序代码:
<html>
<head><title>a</title>
<body>
    <input type="button" onclick="window.open('b.html','','width=200px;height=200px;');" value="调用B页面"/>
    <input type="text" width="50px"/>
</body>
</html>



B页面
程序代码:
<html>
<head><title>b</title>
<body>
    <input type="button" onclick="alert(window.opener.location.href);window.open('c.html','','width=300px;height=300px;');"  value="调用C页面"/>
</body>
</html>



C页面
程序代码:
<html>
<head><title>c</title>
<body>
        <br><br><br><br>
    <input type="button" onclick="alert(window.opener.opener.location.href);window.close();" value="刷新A页面"/>
</body>
</html>



希望对人有点帮助..呵
#8
leapceo2008-12-12 16:37
回复斑竹,我在B页点击回复按钮的同时,执行window.open打开C,并window.close关闭B页

问一下斑竹,我试着用你的方式在我的程序好象还是不好用,我调整程序后,3个页面都没关闭,在C页点击按钮可以关闭C页,但好象A页还是没反映,我在回去试试吧
#9
bygg2008-12-12 16:44
我写的方法是没有写刷新A页面的,
window.opener.opener.location.href=window.opener.opener.location.href;这样就可以在C页面对A页面进行刷新..

因为我没有关闭B页面,关闭了B页面,就找不到A页面了...
#10
leapceo2008-12-15 09:50
斑竹,我照你的方法试了没反映,我是结合ASP写的,我在C页处理完回复后,执行下面的语句
<%
Response.Write "<script language=javascript>"
Response.Write "alert('[批示]操作成功!');"
Response.Write "window.opener.opener.location.href=window.opener.opener.location.href;"  '刷新A页
Response.Write "window.close();"  '关闭本页,也就是C页
Response.Write "window.opener.close();"  '关闭B页
Response.Write "</script>"
%>

[[it] 本帖最后由 leapceo 于 2008-12-15 11:00 编辑 [/it]]
1