0

I'm on a project with vuejs2 through quasar-framework.

This is an iframe that loads an external url by its src attribute:

<iframe id="admin_iframe" :src="adminUrl" style="width:100%" frameborder="0"></iframe>

When I try to get the content iframe like this:

document.getElementById('admin_iframe').contentWindow.document.body.innerHTML;

I'm getting the error:

Uncaught DOMException: Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame.

The iframe content is a form with some fields that I can edit and save the changes (It works) but I need to do a comfirm after making some change without doing the save when the user clicks to go back or go to another path.

So I need to check in some way if any of the fields have changed.

ricopo
  • 455
  • 6
  • 17
  • 1
    Do you control the domain contained in that iframe? If so, you need to set a CORS header on that site to allow the framing site to access it. If it's a third-party website, you will not be able to access it. – Daniel Beck May 16 '17 at 15:47
  • @DanielBeck Thank you! Yes I control the domain, it's my own server. The header is established so `Access-Control-Allow-Origin: *` Should it work or am I missing something? – ricopo May 16 '17 at 16:11
  • That *should* work, but you're on localhost, this may still be a problem: http://stackoverflow.com/questions/10883211/deadly-cors-when-http-localhost-is-the-origin#10892392 – Daniel Beck May 16 '17 at 16:12

0 Answers0