比如:父窗口
<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>
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
这几个都可以刷新 opener.document.location.reload() 父窗口代码:
protected void gvReader_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = gvReader.Rows[e.NewEditIndex].Cells[0].Text;
Response.Write("<script language='javascript'>window.showModalDialog('ReaderEdit.aspx?id=" + id + "','window','DialogHeight:480px;DialogWidth:900px;scroll:no;status:no');</script>");
}
子窗口代码:
protected void imgbtnOK_Click(object sender, ImageClickEventArgs e)
{
UpdateText();
Response.Write("<script>window.alert('修改成功!')</script>");
Response.Write("<script language=javascript>window.close();</script>");
}
如何实现关闭子窗口后,自动刷新父窗口的数据 父窗口的名字为:ReaderBrowing.aspx
子窗口的名字为:'ReaderEdit.aspx
UpdateText();为更新数据函数
提问者采纳 2010-03-26 15:05 protected void gvReader_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = gvReader.Rows[e.NewEditIndex].Cells[0].Text;
Response.Write("<script language='javascript'>window.showModalDialog('ReaderEdit.aspx?id=" + id + "','window','DialogHeight:480px;DialogWidth:900px;scroll:no;status:no');window.location=window.location;</script>");
}
这样可以刷新的。
如果你加一个按钮ID=btnHid,把按钮的宽和高设置成0,该按钮的点击事件和你页面中查询按钮事件写成一样的。那样的话。你把上面的window.location=window.location替换成document.getElementById("btnHid").click()也可以实现子窗口关闭,父窗口刷新的
|