有時咱們須要在新打開的窗口裏面編輯信息,等編輯完了,須要將當前窗口關閉而且刷新父窗口,以使修改生效,本文就是介紹用 javascript 來實現"更新記錄後關閉子窗口並刷新父窗口".javascript
父窗口代碼:html
-
<a href="javascript:void(0)" onclick="window.open('child.html','child','width=400,height=300,left=200,top=200');">打開子窗口
</a>
子窗口代碼:java
<script language="JavaScript" type="text/javascript">spa
-
<!--
-
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>