parent.postMessage does not seem to work

I have a demo for parent.postMessage and it does not seem to work.

Does anyone know how to solve this?

I also have same example on https://codesandbox.io/p/sandbox/parent-iframe-73t82v

any ideas @curran, we really need this problem solved to use VizHub at scale.

Note, @wildone works with me on our joint project, but knows a hell of a lot more.

Please help

1 Like

Interesting! Can you please describe the larger problem you are trying to solve by having two iframes talk to each other?

I wonder if it might be a matter of enabling some additional flags on the iframe from the VizHub side.

I’ve made the example showcasing the usecase, link in the original post. I have this working hosting from github, without any issues. Load up the example and try sending text to and from iframes.

I investigated this a bit, and discovered that it’s likely due to the fact that there are 2 levels of iframe nesting. The VizHub embed actually renders an iframe within the embed snippet iframe, and that’s probably why the messages are not getting out.

The reason why it is set up like this with the nested iframes is so that the inner iframe can potentially re-render as the code in VizHub is updated. However, this feature is not necessary for all embedding use cases and I was considering introducing a new endpoint that serves the raw html, it eliminating the two levels of iframe, which would solve your messaging need. For that to work and be secure, though, it would need to be served from a separate domain (otherwise the viz code could “hack into” VizHub and call all its internal APIs).

Here’s my proposal: add an option for “raw hosting”, which will serve the viz under vizhub.io. What do you think?