子 window 关闭后刷新父页面动态 2011
Refreshing parent page after child window is closed dynamics 2011
这是在 Microsoft Dynamics 2011 的上下文中。我正在使用 showModalDialog 打开一个网络资源。这个问题是严格针对 IE 的。我尝试使用 window.unload 在模式对话框关闭后刷新父页面,使用此代码:
window.onunload = refreshParent;
function refreshParent() {
window.opener.location.reload();
}
并且还尝试使用 setInterval 从父页面轮询模态页面的关闭状态,并在关闭时触发刷新,但 none 似乎有效。想知道是否有人有任何想法...
首先,请注意:showModalDialog()
在所有现代浏览器中都已弃用。 虽然它在 IE 中起作用(包括在版本 11 中),但它是Edge 不支持。您需要更改此实现只是时间问题。我强烈建议您考虑不使用此方法的替代解决方案。
也就是说,如果您决定使用 showModalDialog()
,请考虑将函数调用分配给一个变量。在模式页面中,您可以分配给 window.returnValue
属性 以传递您想要的任何数据。
在主页代码中,您可以检查变量的值,并采取相应的措施。这是一种方法:
主页:
var returnedFromModal = window.showModalDialog(/* your options here*/);
if (returnedFromModal) {
window.location.reload();
}
模态:
/* ... other modal-related code ...*/
window.returnValue = true;
可以在此处找到更多文档:https://developer.mozilla.org/en-US/docs/Web/API/Window/showModalDialog
这是在 Microsoft Dynamics 2011 的上下文中。我正在使用 showModalDialog 打开一个网络资源。这个问题是严格针对 IE 的。我尝试使用 window.unload 在模式对话框关闭后刷新父页面,使用此代码:
window.onunload = refreshParent;
function refreshParent() {
window.opener.location.reload();
}
并且还尝试使用 setInterval 从父页面轮询模态页面的关闭状态,并在关闭时触发刷新,但 none 似乎有效。想知道是否有人有任何想法...
首先,请注意:showModalDialog()
在所有现代浏览器中都已弃用。 虽然它在 IE 中起作用(包括在版本 11 中),但它是Edge 不支持。您需要更改此实现只是时间问题。我强烈建议您考虑不使用此方法的替代解决方案。
也就是说,如果您决定使用 showModalDialog()
,请考虑将函数调用分配给一个变量。在模式页面中,您可以分配给 window.returnValue
属性 以传递您想要的任何数据。
在主页代码中,您可以检查变量的值,并采取相应的措施。这是一种方法:
主页:
var returnedFromModal = window.showModalDialog(/* your options here*/);
if (returnedFromModal) {
window.location.reload();
}
模态:
/* ... other modal-related code ...*/
window.returnValue = true;
可以在此处找到更多文档:https://developer.mozilla.org/en-US/docs/Web/API/Window/showModalDialog