使用 onunload 关闭弹出窗口后刷新 div
我当前正在使用以下代码,该代码打开一个弹出窗口,并在弹出窗口关闭时刷新父窗口。
父/打开弹出链接代码
<script type="text/javascript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=600,left = 433,top = 84');");
}
// End -->
</script>
<a href="javascript:popUp('reminder.php?order=1234&delete')">Open the Popup Window</a>
弹出窗口代码
<body onunload="window.opener.location=window.opener.location;">
是否可以编辑此代码,以便不刷新整个父窗口,而只刷新特定的 div(及其内容) ?我希望可以使用像 getelementbyid 这样的东西。
弹出窗口用于删除存储在数据库中的提醒。删除提醒后,我希望该 div 为空白(表明已删除)。它不需要刷新,只需删除其内容即可。
谢谢 :)
I'm currently using the following code which opens a popup window, and refreshes the parent window when the popup is closed.
Parent / Open Popup Link Code
<script type="text/javascript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=600,left = 433,top = 84');");
}
// End -->
</script>
<a href="javascript:popUp('reminder.php?order=1234&delete')">Open the Popup Window</a>
Popup Window Code
<body onunload="window.opener.location=window.opener.location;">
Is it possible to edit this code so that instead of refreshing the entire parent window it only refreshes a specific div (and its contents)? I'm hoping something like getelementbyid could be used.
The popup window is used to delete reminders that are stored in a database. After deleting a reminder I'd just like that div to be blank (indicating thats it deleted). It doesnt need to refresh as such, simply its contents need to be removed.
Thanks :)
您可以在父级(打开器)中创建一个全局函数,并且只要它们位于同一域,您就可以调用它:
然后在弹出窗口中:
You can create a global function in the parent (the opener) and provided they are on the same domain you can call it:
Then in the popup: