Closed juliadou closed 4 years ago
Both sites should be able to postMessage each other. From the portal host, you can use the HTMLPortalElement.postMessage() API. The other way around you need to use the portalHost interface, window.portalHost.postMessage().
The other option is to listen to the load event on the
Thank you! I tried portal.onload and it works great.
Regarding window.portalHost.postMessage, If I add it to Site B so Site B can post message to Site A, how can Site A receive the message? I tried to add window.addEventListener('message', callback)
to Site A and it does not seem to work.
The message gets dispatched on the portal element, so you need to use portal.addEventListener('message', callback')
.
This seems like a duplicate of #26, so I'll consolidate there. However it sounds like from @lucasgadani's comments Chromium implements the load event, so that's good input for #26 :).
After I create a portal with Site B in Site A, i would like to detect whether the portal content is loaded. Is there a way to achieve this?
I initially thought it could be achieved using messaging, but it seems only Site A can message the portal (Site B) and not vice versa.