Search code examples
javascripthtmlfirefoxdomsame-origin-policy

Can't get reference to existing window


I need to get a reference object to a window in Firefox which was not opened by the current page, but is of the same protocol, port and host. So complies with the same-origin policy.

I was using the code below to do this:

var mainWindow = window.open('', ''MAIN_WINDOW');

This was working before Firefox 52, however since the 52 update this code just opens a new blank tab, instead of referencing to the currently open window. I've looked at the fixes in the 52 release and I can't see anything which would have directly effected this.

Doing console.log(window.name) in the window I want reference to returns ' MAIN_WINDOW'. So The window name is correct.

I am then trying to access the frames array within the window reference later on in the code. Is there a way to solve this issue or an alternative I can try?


Solution

  • If the windows are same-origin you can use a BroadcastChannel to let separate windows or tabs talk to each other