有两个窗口:  A窗口(父),B窗口(模态)A窗口里有一个DATAGRID,一个按钮。点击按钮时,弹出B窗口(模态)。在B窗口中添加数据,提交后,要求B窗口自关闭,然后刷新A窗口(父)试了网上的大部分方法,都不能实现。  唯独一个在B窗口(模态)的<body>里面添加<onunLoad="window.dialogArguments.location.reload();">这个方法能实现父窗口刷新,但是不能关闭。只要关闭就提示“window.dialogArguments.location”为空。
希望各位能帮帮忙,并以代码赐教~~~谢谢!!!!(解决立马结贴~~~)

解决方案 »

  1.   

    onunload="if (window.opener) window.opener.history.go(0);"
      

  2.   


    直接在父页面写刷新代码。因为模态对话框不关闭的话,下面的代码等待返回值不执行,可利用此特性.
    <script type="text/javascript"> 
    function doit(){
      r = showModalDialog("test1.asp");
      location.reload();
    }
    </script>
    <input type="button" onclick="doit()">
      

  3.   


    有可能是showModelessDialog函数打开的窗口
      

  4.   

    模态窗口不能用opener...所以试了,不能用!!!
      

  5.   

    <script type="text/javascript">  
             function openSubWin()   
    {
        window.showModalDialog('b.html', 'newwindow', 'height=500, width=400, top=0, left=0, toolbar=no, menubar=yes, scrollbars=yes,resizable=yes,location=no, status=no'); 
       window.location.reload();
    }  
    </script>弹出子窗体b.html , 当关闭子窗体时 触发父页面刷新
      

  6.   


    在成功提交的代码之后加一句;ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.opener.location.reload();window.close(); </script>");
      

  7.   

    楼主给你一个例子:  function ShowNewWin() {
                var w = window;
                window.showModalDialog("_JSarray.aspx",w,"");
            }
    _JSarray.aspx:<input id="Button1" type="button" value="button" onclick="CloseWin()" />
     function CloseWin() {
            window.dialogArguments.location.href = window.dialogArguments.location.href;
            window.focus();
            window.close();
        }可以关闭打开的模态窗口并且刷新父页面
      

  8.   

    试了下,是能刷新,看到状态条刷了一次!可是datagrid并没有重新绑数据。