关闭子页面后无法重新加载页面

时间:2013-08-12 11:37:26

标签: javascript html

关闭子页面后,我无法自动刷新父页面。我知道之前曾问过这个问题,但我无法解决使用它们的问题。以下是我的父页面(parent.php)。

<html>
<head>
<script type="text/javascript">

var popupWindow=null;

function child_open()
{ 

popupWindow =window.open('child_page.html',"_blank","directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=600, height=280,top=200,left=200");

}
function parent_disable() {
if(popupWindow && !popupWindow.closed)
popupWindow.focus();
}
</script>

</head>
<body onFocus="parent_disable();" onclick="parent_disable();">
    <a href="javascript:child_open()">Click me</a>
</body>    

</html>

这是我的child_page.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<h1>child page</h1>

This is the child page
<body>

<script>
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.location.reload();
    }
</script>
</body>
</html>

2 个答案:

答案 0 :(得分:0)

脚本:

function RefreshParentPage() {
                window.self.close();
                window.opener.location = 'your parent page path';
                top.location.reload();
            }

HTML:

<a onClick="RefreshParentPage()" href="#">Close Child Page</a>

答案 1 :(得分:0)

这与Mozilla完美配合。

相关问题