I've to pass some data from iframe
to parent.
iframe
code
window.parent.postMessage({message: 'Test'}, "*");
Parent Code
window.addEventListener('message', function (e) {
alert('Received message 1 : ' + e.data.message);
document.getElementById('ExchangeID').value=e.data.message;
}, false);
This works fine in Firefox, Chrome, Safari. When i run this in IE9 , I get an error that e.data.message
is undefined.
What is missing here ?
From the Can I Use... page on Cross-document Messaging:
Partial support in IE8-9 refers to only working in frames/iframes (not other tabs/windows). Also in IE 9 and below an object cannot be sent using postMessage.
You can, however, use the alternative syntax:
window.parent.postMessage("test", "*")