0

我是 Javascript 新手,所以请多多包涵。

我有代码在子窗口关闭时刷新父窗口的 div。问题是当 div 的内容刷新时它会创建一个副本,我不知道为什么。我的代码如下。

head父母的标签内,我正在这样做:

<html>
<head>
<script language="javascript" type="text/javascript">
function ParentWindowFunction()
{
    $(".mydiv").load("Welcome.jsp");
    return false;
}
</script>
</head>
<body>

<div class="mydiv">
    <img src="<s:property  value="#session.img"/>"  id="img"  width="200"  height="150" />
</div>
</body>

</html>

在子窗口的head标签内,我有:

<html>
<head>
<script type="text/javascript">
function refreshAndClose() 
{

    window.opener.ParentWindowFunction();

    window.close();
}
</script>
</head>
<body  onbeforeunload="refreshAndClose();">
...
</body>
</html>
4

1 回答 1

0

我找到了解决问题的方法,而不是刷新 div 我正在重新加载整个页面,就像这样

<script>     
    function winopen()
    {
        chatterinfo = window.open('fileupload.jsp',"chatterwin","scrollbars=no,resizable=yes, width=400, height=300, location=no, toolbar=no, status=no");

        chatterinfo.focus();        
    }
</script>
<script language="javascript" type="text/javascript">
    function ParentWindowFunction()
    {
        window.location="Login.action?uname=${uname}&&pass=${pass}";
    }
</script>
</head>
<body>

<div class="mydiv">
<img src="<s:property  value="#session.img"/>"  id="img"  width="200"  height="150" />
</div>
</body>
</html>

在子窗口的头部标签内,我有:

<html>
<head>
<script type="text/javascript">
    function refreshAndClose() 
    {
        window.opener.ParentWindowFunction();
        window.close();
    }
</script>
</head>
<body >
<input type=button onclick="refreshAndClose();" />
</body>
</html>
于 2012-09-05T09:04:53.057 回答