There is a foreign site, in the iframe of which the page of my site is open. My JS opens ( window.open ) a new window with another page from my own site. The event in this window must be "reported" to the original frame about the event, and then close this window.

Is such a scheme realizable?

I don’t understand how to report something from the window into the "spawned" frame.

  • I understand that a frame on your page is embedded on another site, and a window opens on your page. In the window an event occurs, then who should get an answer? Another website or your website? - lampa
  • The answer should get my site: that his page is open in the frame. - Sergiks

1 answer 1

self.opener : self.opener addresses the window that spawned this.

Those. on the event, in the "new window" works something like this code:

 /* из окна вызываем метод "родителя", в данном случае это тот iframe */ self.opener.receiver("в новом окне произошло событие!"); self.close(); 

In the original page, which is in the iframe, the description of this method is "receiver":

 function receiver( msg){ alert( msg); }