2013-10-02 39 views
3

假设我在页面上有多个iframe,并且其中一个发送了发布消息。是否有一种简单的交叉浏览方式来检测哪个人做了它并能够回复?检测哪个iframe发送了发布消息

我看到消息eventsource财产,但我无法响应通过它使用event.source.contentWindow.postMessage

Error: Permission denied to access property 'contentWindow'

+2

如果有人将寻找的解决方案同样的问题,我可以分享我发现的。只需将消息中的iframe ID与其他数据一起发送即可。简单的方法读取iframe中的iframe的ID的设置与工作期间的“name”属性和获取window.name属性类似。 – user2281966

回答