I have a site that has an HTML element containing a chart I’m trying to pass data from a Wix collection to with the HTML “onMessage” function like so once it’s ‘ready’ so it’s loaded correctly
However, when putting logs withing the if (event.data.type === ‘ready’) condition, it is accessed multiple times, sending the data multiple times as well which is problematic for my implementation.
My ready function is as so
function ready() {
window.parent.postMessage({"type":"ready"}, "*");
}
When logs are placed inside this function, it seems it’s only called once however, so I have no idea as to the source of the problem or why I am getting the behavior I am.
In order to locate the problem, can you please try to check if the ifrmae post to parent several times or only once?
Can you try to see if it only happens when you post onLoad or also on other events?
Can you see when you refresh the page (the browser), how many times it fires?
Let me understand if I got it right.
When you refresh the page it fires once.
When you navigate to another page it fires twice.
When you navigate to the third page it fires 3 times
and so on…
The code is only present on one page, and when I load that page, or refresh it, I only see the log “Only shows up once” one time, each time I load that page
The log from the Wix website, in the wix console, has the code from my Wix page code firing multiple times, as if it has been received multiple times; this DESPITE that the iframe, whose logs I can only see in the ‘Inspect’ browser console, says it is only sending that message 1 time. I’ll try show what I mean in images.