0

I have an app running within a webpage. Basically the form is in a different frame and my code is in different frame.

When trying to access the parent frame I'm getting the below error:

Uncaught (in promise) DOMException: Blocked a frame with origin "http://localhost:10001" from accessing a cross-origin frame.

I will not be able to change the domains of both the page to same as I don't have access to the complete document.

Is there a workaround to access the element from another frame.

1 Answers1

0

You can't access an with different origin using JavaScript.

If it's just a local env situation, you can disable your browser built-in Cross-Origin protection (don't forget to turn it back on !).

You should then be able to use Window.frameElement the access the parent of your iframe.

Please have a look at this answer which greatly explains : SecurityError: Blocked a frame with origin from accessing a cross-origin frame

Thomas G.
  • 61
  • 1
  • 6