I'm trying to send a simple message from a child document (an iframe) back to its direct parent using the window.postMessage API.
Within the parent document I have the following:
window.addEventListener("message", receiveMessage, true);
var receiveMessage = function(event) {
console.log("Recieved event " + JSON.stringify(event));
}
Then, in the iframe I have the following:
window.parent.postMessage('message', '*');
Based on everything I've read, this should work and my log message should be written to the console. Except it's not working.
I'm aware that using the * as the targetOrigin is not always secure, but at this point I just want to sort out the linkage.
Any ideas or anything obvious that I'm missing?