简体   繁体   中英

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. Into this iframe the main window loads few different windows. 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. Is there any way to make it work cross- browser and especially in IE ? I need backward compatibility up to and including IE 8. I attached a scheme of the architecture of the site 在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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