0

This is a common problem related to cross-origin. I have a Page base.html with window.open('foo.html') and foo.html with a JavaScript function called faa().

base.html and foo.html are in the same domain (in this example, in the same directory too).

Have a look at this code:

<script>
        var opened_foo;

        $('#openfoo').click(function() {
            opened_foo= window.open('foo.html','_blank');
        });

        $('#dofaa').click(function() {
            opened_foo.faa("hello");        
        });
    </script>

The command opened_foo produced an error:

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

The error is pretty simple. My base.html seems to not have an "origin". But why? What do I need to do?

ToastyMallows
  • 4,203
  • 5
  • 43
  • 52
RetroMime
  • 387
  • 1
  • 8
  • 23
  • 3
    "base.html and foo.html are in them same domain" — They error message is that the origin is `null` which implies they are not on the same domain … or any domain at all, but you are loading local files. – Quentin Mar 29 '18 at 14:48
  • Yeah! Seems loading file locally is not considered "same domain". Using apache to load the two html pages, resolve the problem. Thank you. – RetroMime Mar 29 '18 at 15:01

0 Answers0