JS Guys - Accessing an iFrame's DOM from parent document - possible?

Hi everyone, hopefully someone can assist here.

We have an embedded iframe and we’re trying to access the url of the iframe.

However, we’re consistently getting blocked by CrossOrigin policies (despite X-Frame being set to Allow in Bubble).

Has anyone had any luck with accessing the URL of the iframe within a document from the parent page?

This is the code we’re trying but still gets blocked:

Happy to pay for a solution of course!

Reece

Not a JS guy but have 2p thoughts.
IIRC, iframe should never be able to talk outside with parent.

Unless there is a js script on both sides that communicates.

So you’ll need access to the server serving content from inside the iframe. And the server hosting the iframe.

Had a client where we needed to iframe a bubble dashboard in his main wordress.
Couldn’t get responsive to work. Although this plugin is quite useful. http://www.tinywebgallery.com/blog/advanced-iframe

Ended up in some dark corners of iframe/js.

Hope this helps
ZubairLK
https://www.linkedin.com/in/zubairlk/

1 Like

Hi Zubair,

Thanks a lot for that - the client controls both the parent website and iframe website so I think we can put a script in both to communicate somehow. Thanks for the link - shall take a look!

Reece

Try using window.postMessage on both to create a two way communication (:

1 Like

Thanks!

We ended up achieving it using Cookies :slight_smile: