Good Night

导航

关闭子窗口刷新父窗口

方法一:
窗口模式对话框刷新(前提是不使用:IsPostBack )
self.window.location.reload();
方法二:
top.window.close();top.window.close();window.dialogArguments.location.reload();return false;
第一句是前闭当前窗口;第二句关闭确定对话框窗口;第三句重新加载;如果使用服务器控件的时候,必须使用最后一句。
方法三:
刷新当前页面:
window.location.href=window.location.href;
方法四:
服务器端注册JS刷新框架窗口:
ClientScript.RegisterStartupScript("", "<script language='javascript'>parent.框架名.location.href=parent.框架名.location.href;</script>");
方法五:
父窗口可以接收子窗口的返回值:
父窗口JS代码:

<script language="javascript" type="text/javascript">
function openChild()
{
  var k = window.showModalDialog(url,window,"dialogWidth:600px;status:no;dialogHeight:500px");
  if(k == 1)
  {
    alert("刷新");
  }
}
</script>

子窗口JS代码:

<script language="javascript" type="text/javascript">
function winClose(isRefrash)
{
  window.returnValue=isRefrash;
  window.close();
}
</script>

调用方法:winClose(1)

window.showModalDialog(“b.html”)打开的页面:

1 history.go(0);

2 location.reload();

3 location=location;

4 location.assign(location);

5 document.execCommand('Refresh');

6 window.navigate(location);

7 location.replace(location);

8 document.URL=location.href

这几个都可以刷新比如:

父窗口 <a href="javascript:void(0)" onclick="window.open('child.html','child','width=400,height=300,left=200,top=200');">打开子窗口</a>

子窗口 <script language="JavaScript" type="text/javascript"> <!-- function refreshParent() { window.opener.location.href = window.opener.location.href; if (window.opener.progressWindow) { window.opener.progressWindow.close(); } window.close(); } //--> </script>

<a href="javascript:void(0)" onclick="refreshParent()">刷新父窗口并关闭当前窗口</a>

window.opener.parent.location.reload();

opener.document.location.reload() ;

window.opener.document.location.reload();

以上这些方法都是我在网上搜索的,下面介绍下我自己用到的方法吧!

下面设a.jsp为父页面,b.jsp为子页面。

a.jsp中:

<script type="text/javascript">

function updateunit(id)
{
  window.open('showunitrent.do?method=toupdate&id='+id,'update','scrollbars=yes,width=650,height=400,top=150,left=250');
}
</script>

b.jsp提交后

<script type="text/javascript">
  alert("修改成功!");
  window.close();opener.location.reload();
</script>

这样就可以刷新父页面,关闭子页面了。但是如果你的a.jsp页面是在java文件中生成的,用的是:。。。。javascript:window.open('showunitrent.do?method=toupdate&id='+id,'update','scrollbars=yes,width=650,height=400,top=150,left=250');
那么在b.jsp页面上就可以用:

<script type="text/javascript">
  alert("修改成功!");
  opener.location.reload();
  window.close();
</script>

posted on 2013-04-23 11:57  胡同。  阅读(1847)  评论(0编辑  收藏  举报