IFrame communication

From parent to child and from child to parent.


Container is not ready

// child
document.addEventListener('DOMContentLoaded', () => {
    window.parent.notifyAboutReady();
});
window.updateValue = (value) => {
    document.getElementById('counter').innerText = value;
}

// parent
window.notifyAboutReady = () => {
    document.getElementById('is-ready-container').innerText = 'Container is ready'
}
document.addEventListener('DOMContentLoaded', () => {
    const frame = window.frames['container'];

    let i = 0;
    setInterval(() => frame.updateValue(i++), 1_000);
});