Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个客户建议我实现一个旧版本的 easyXDM 来将简单的跨域消息从 iframe 内容发送到其父窗口。我的最低浏览器要求是 IE11 及更高版本。
为什么我应该在 window.postMessage 之类的东西上使用它?
我认为您无法使用 easyXDM 实现您想要的,如文档所述:
easyXDM 提供了一个传输堆栈,能够在两个窗口之间传递基于字符串的消息,一个消费者(主文档)和一个提供者(使用 iframe 包含的文档)。
easyXDM 文档
这意味着您可以将消息从父窗口发送到包含的 iframe,但反之则不行。
这就是坚持使用 window.postMessage 方法的充分理由。