Hi,
I am having trouble using postMessage, even after reading other posts online and on this website. I am hoping you guys can help me out.
I have an iframe that is generate using var abc_iframe = document.createElement('iframe'). From my understanding I am suppose to attach an event listener to this to listen to message from within the iframe.
I have tried:
1. abc_iframe.addEventListener("message", function(e){ console.log(e.data); }, false);
2. document.frames['id_iframe'].addEventListener("message", function(e){ console.log(e.data); }, false); (id_iframe right here being the id of the iframe)
3. WinJS.Application.addEventListener("message", function(e){ console.log(e.data); }, false);
None of these have worked.
I am sending the postMessage from within the iframe using
1. parent.postMessage("message", "ms-appx://" + document.location.host);
2. window.parent.postMessage("message", "ms-appx://" + document.location.host);
The iframe content is hosted on another domain (not locally).