Search code examples
javascripthtmlreactjsextjswebapi

can iframe capture the data before it complete loads using window.PostMessage()


Can iframe capture data when it is still in the process of loading? or does it need to be completely loaded to receive data from parent using window.postMessage() method?

I'm working on analytics I need the data to be passed to an iframe form parent before it loads. Because I need to send onload page details to adobe as soon as it iframe loads. the method will automatically triggered on load of iframe so i need data before it loads.

When i did settimeout with 5 seconds, the iframe did receive the data. But i want before it loads.


Solution

  • We can only pass the data to completely loaded iframe using window.postMessage.