Sending message back with postmessage

If I'm looking at this right, in Website 2 in the sendMessage() function, it looks like you are getting the newly created iframe element, and then posting a message to it. Where in reality you really want to post a message to website 1.

From website 2...try something like

window.parent.postMessage("hello website 1", "*");

To respond to the Event.origin domain, you have at your disposition the message's Event.source

// Child website:
window.addEventListener("message", evt => {
    // if (evt.origin !== "http://example.com") return;

    console.log(evt.data) // "Question!"
    evt.source.postMessage("Response!", evt.origin);
});

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#The_dispatched_event

source
A reference to the window object that sent the message; you can use this to establish two-way communication between two windows with different origins.