I have one EditorX page embedded in an iframe – how it can handle a message from the parent?
It know I can send the data to the parent from this iframe by wixWindow . postMessage
But how to listen/receive message by the iframe from the parent (the other direction)?
Because Velo blocks “window”, it’s not possible to set an window.onmessage event handler. How to set this handler in Velo?
The page can receive messages from the HtmlComponent with the onMessage() event handler . Messages are sent to the HtmlComponent with the postMessage() method .
For more information, see the article Working with the HTML Component in Velo , especially the section on Messaging .
That’s how the parent page can exchange messages with an iframe.
My question was how to exchange messages inside the iframe by page served by EditorX that blocks native JS window.onmessage .
@petrmeissner I don’t understand what you mean by “exchange messages inside the iframe”. If you have the HtmlComponent set to the page served by an EditorX site (or any other site for that matter) by using the .src property of the HtmlComponent, then what exactly are you trying to exchange messages with?
The HtmlComponent allow messages to be exchanged between embedded code (in the HtmlComponent) and the parent page. However, you can’t exchange messages between an embedded page and the parent page.
You will need to provide more information. How have you set up the HtmlComponent? What exactly is in it? What else is in the HtmlComponent that you want to exchange messages with?
I have the same problem. Wix is blocking Window.onmessage to listen to the events of an Iframe, which by the way is an Iframe from their own site. We are just trying to allow postMessage between the iframe and the home site but it seems it is impossible?
I didn’t write about suing HtmlComponent.
I requested an option to run/embed EditorX page inside an iframe of a different site. NOT having an iframe inside EditorX.
No, you can accomplish this. I have two separate iFrame elements communicating with my page code. (And yes, while you can’t use window.onMessage inside of your frontend code, you can use window inside of the iFrame script, and you can simply use $w(‘#htmlwhatever’).onMessage as an event listener inside of your frontend code. Depending on what you want to do, these two links should be very helpful to you.
Watch this.
and you can also read this
https://www.keysolutionsin.com/post/connecting-the-wix-database-to-a-custom-html-element-using-velo-javascript
Hey Bryan,
So kind of you to reply so quickly! Thanks for your help. It’s crazy but this is not an external iFrame, I am putting together an online programme through Wix Dashboard. Once you finish the programme, the site loads it via an iFrame, but it is not possible to interact with it, it doesn’t recognise it as an htmlcomponent, it doesn’t come with the .onMessage function and it throws errors constantly. Basically it doesn’t work.
I guess then Wix will not provide the solutions I need and will have to find another provider. I’ll write to them to see if they can fix it, but I doubt this will be a priority. Let’s see what happens.
I thank you so much!