iFrame 和父页面之间跨域通信的可能方法

发布于 2024-08-31 12:09:54 字数 81 浏览 4 评论 0原文

请建议从 iFrame 触发父页面事件的可能技术。我尝试了 url Hashing 和使用 window.postMessage 技术,但没有成功。

Please suggest possible techniques to trigger events in parent page from an iFrame. I tried out url Hashing and using window.postMessage techniques but without any success.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

聚集的泪 2024-09-07 12:09:54

easyXDM 正是为此目的而设计的。
您可以在 http://easyxdm.net 找到它,它有很多示例。

总而言之,它允许两个窗口使用字符串或 RPC 调用“自由”地进行通信。

请参阅http://consumer.easyxdm.net/current/example/methods.html 用于 RPC 演示之一。

easyXDM is designed for this exact purpose.
You can find it at http://easyxdm.net and it has quite a few examples.

To sum it up, it allows two windows to communicate 'freely' using either strings or RPC calls.

See http://consumer.easyxdm.net/current/example/methods.html for one of the RPC-demos.

伤感在游骋 2024-09-07 12:09:54

没有成功,因为出于安全原因你不能成功。

No success because you cannot for security reasons.

要走就滚别墨迹 2024-09-07 12:09:54

这个问题的现代答案是新的跨文档消息传递(Web Messaging API)

请参阅此处的 Opera 介绍:

http://dev.opera.com/articles/view/window-postmessage-messagechannel/

或此处的规范:http://www.w3.org/TR/webmessaging/

The modern answer to this question is the new cross-document messaging (Web Messaging API)

See Opera's introduction here:

http://dev.opera.com/articles/view/window-postmessage-messagechannel/

Or the specification here: http://www.w3.org/TR/webmessaging/

追星践月 2024-09-07 12:09:54

我想到的唯一想法是在服务器端有一个脚本,iFrame 将其事件发送到该脚本(与唯一 ID 结合),并且父页面可以轮询(通过其域上的服务器脚本或 JSONP)。不过,这需要做很多工作,并且需要父页面和 iframe 的配合。

The only idea that comes to mind is to have a script on server side that the iFrame sends its events to (combined with a unique ID) and that the parent page can poll (either through a server script on its domain, or JSONP). That's a lot of work to do, though, and requires cooperation from both the parent page and the iframe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文