简体   繁体   English

如何在卸载主窗口时关闭从主窗口的iframe打开的窗口

[英]How to close windows that was opened from iframe of main window on unload of main window

I have a main window , inside of this window there is an iframe. 我有一个主窗口,在此窗口内有一个iframe。 Into this iframe the main window loads few different windows. 在此iframe中,主窗口加载了几个不同的窗口。 From those windows there are windows that are opened - they are NOT modal and site architecture won't allow to make them modal. 在这些窗口中,有一些打开的窗口-它们不是模态的,并且站点架构不允许将它们设置为模态的。 I need to close all those windows that were opened from all those iframe windows on unload of MAIN window. 我需要关闭在卸载主窗口时从所有iframe窗口中打开的所有窗口。 Is there any way to make it work cross- browser and especially in IE ? 有什么方法可以使其跨浏览器工作,尤其是在IE中? I need backward compatibility up to and including IE 8. I attached a scheme of the architecture of the site 我需要IE 8之前(包括IE 8)的向后兼容性。我附加了该网站的体系结构方案 在此处输入图片说明

Take the handle of the window when you open them and assign a callback function to the opener, something like: 打开窗口时,请握住窗口的手柄,然后将回调函数分配给打开器,例如:

var w = window.open("....");
w.callback = function(){
   if (window){
      return true;
   }
}

Then from inside each opened window have a pooling mechanism which will call the 然后在每个打开的窗口内部都有一个池化机制,该机制将调用

callback

trapped inside a try catch to determine if the opener is still alive. 被困在try catch中以确定开瓶器是否还活着。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM