在 iframe、彈出視窗或對話框中,常需要重新整理父頁面。可依開啟方式選擇 parent、opener 或 dialogArguments 等物件來呼叫 reload。
parent.location.reload();
window.opener.location.reload();
self.opener.location.reload();
window.parent.dialogArguments.document.execCommand('Refresh');若頁面是透過 window.open 開啟,通常可使用 opener 回到父視窗;若是 showModelDialog,則需透過 dialogArguments 取得父層文件。實際使用時應先確認視窗關係,避免找不到對應物件而發生錯誤。