Hi all,
I have a problem with my code - onload of my CRM 2016 OnPremise form I add an eventlistener. On my iframe, I am using window.postmessage, hoping that my listener will then handle the returned variable. However when I debug, the listener seems to set up but when I click the button on the iframe to invoke the postmessage, the code within the listener event does not seem to invoke at all. Can anyone spot anything obvious? Code is below:
IFRAME javascript:
var score = document.getElementById("elementname").innerText; //gets the score ok
window.parent.postMessage(score, window.location.protocol + "//" + window.location.host);
CRM FORM ONLOAD:
function loadListener()
{
if (window.addEventListener)
{
addEventListener('message', listener, false)
}
else
{
attachEvent('onmessage', listener)
}
}
function listener(event)
{
if (event.origin == (window.location.protocol + "//" + window.location.host))
{
alert("hello"); //never runs
alert(event.data);
}
}
*This post is locked for comments
I have the same question (0)