Chrome error when using opener on pop-up window (cross-origin)

359 Views Asked by At

I have a local website containing pop-up windows that should be able to access their parents.

Those pop-up windows are opened as seen here:

open("filename.html", 'name', 'scrollbars=yes,width=700');

And I am trying to set them to access their parent window with window.opener property.

This works fine on Firefox, but not on Chrome, where I get an error:

Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.

I've also noticed that when being uploaded to a server it just works fine on both Chrome and Firefox.

How can I make this work on Chrome when running on local? Is there any alternative to window.opener that allows the child window to acces their parent?

1

There are 1 best solutions below

0
On

I'm having the same problem with a project... My temporal-solution was to set up a local server, for example:

  1. Download http-server:

    $ npm install http-server -g

  2. Look for the project main folder in the console and type:

    $ http-server

  3. The console will show you in which port you can run your website in local

Now you can use window.opener in Chrome. I'd like to have a better solution!

By the way, another idea is replacing child-windows for modals :)