[英]data issue addEventListener in IE9
I've to pass some data from iframe
to parent. 我必须将一些数据从
iframe
传递给父级。
iframe
code iframe
代码
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. 在Firefox,Chrome,Safari中运行正常。 When i run this in IE9 , I get an error that
e.data.message
is undefined . 当我在IE9中运行此命令时,出现错误
e.data.message
未定义 。
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).
IE8-9中的部分支持是指仅适用于框架/ iframe(不适用于其他标签/窗口)。 Also in IE 9 and below an object cannot be sent using postMessage .
同样在IE 9及以下版本中,无法使用postMessage发送对象 。
You can, however, use the alternative syntax: 但是,您可以使用其他语法:
window.parent.postMessage("test", "*")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.