Your HTML page (the host page) has an Iframe. The Iframe source is on other domain, so you will have to use the window.postMessage() for cross-origin communication.
But this communication is only in 1 direction (The Iframe can inform the Host or the Host can inform the Iframe)
This article shows you how to make the Request/Reply communication using postMessage() and MessageChannel combination.
The article did not show you how to add a timeout to the communication, so the Iframe might wait forever if the Host did not response.
I will resume the technique by some codes snippets and at the same time add the missing timeout implementation.