0

我的要求是关闭父窗口时,子窗口也应该关闭。但现在的问题是,即使我刷新父窗口,窗口也会关闭。我不希望刷新关闭窗口。我的代码是

            function closeEditorWarning(){

     for (var i=0;i<childWindow.length;i++) {
           if (childWindow[i] && !childWindow[i].closed)    childWindow[i].close();
     }
    self.close();
     }

          window.onbeforeunload = closeEditorWarning;
4

3 回答 3

0

On browser refresh page gets unloaded and then it loads again. As you are using "onbeforeunload" it gets called before unload, hence "closeEditorWarning" method is getting called. To resolve this issue you can disable browser refresh.

于 2012-12-11T04:09:50.790 回答
0

我删除self.close();了,现在可以正常工作了。

于 2012-12-12T06:59:54.397 回答
0

如果子窗口是您自己的网页,您可以尝试将代码放入子网页中,通过cookie定期检查父窗口是否仍然存在,看看它是否保持“活动”

于 2012-12-11T04:16:52.430 回答