I seem to be encountering an issue with my syntax while attempting to pass a variable to an iframe (for colorbox integration). Currently, I've allowed all domains on both ends for testing purposes. Here is the JavaScript code for the sender page:
$(document).ready(function() {
if(window.location.hash) {
var urlimage = window.location.hash.substring(1);
targetiframe = document.getElementById('wbgallery').contentWindow;
targetiframe.postMessage(urlimage, "*");
console.log(urlimage);
}
});
Here is the code for the receiver page:
$(document).ready(function() {
window.addEventListener('message',receiveMessage);
console.log(event);
function receiveMessage(event) {
if (origin !== "*")
return;
inbound = event.data;
console.log(inbound);
}
});
While I can see the console log for urlimage and observe an event, there seems to be no output for inbound. I'm referring to Mozilla's documentation to troubleshoot this.