Javascript:框架之间的通信

发布于 2024-09-29 20:15:06 字数 189 浏览 0 评论 0原文

我有两个不同的应用程序加载到不同的框架中。 我需要他们沟通 我知道javascript安全模型不允许从不同域加载的框架进行通信 但由于我控制这两个应用程序,也许有一种方法可以允许从特定的另一个域加载的框架与该框架进行通信

如果不可能,那么有什么破解方法? 应用程序不同,我需要在不同的域(或至少不同的端口)加载它们 我无法将它们作为一个应用程序运行

I have two different applications loaded into different frames.
I need them to communicate
I know that javascript security model does not allow frames loaded from different domains to communicate
but since I control both applications maybe there is a way to allow frames loaded from specific another domain to communicate with this frame

If it is not possible what's the hack around?
Apps are different and I need to load them at different domains (or at least different ports)
I can not run them as one app

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

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

发布评论

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

评论(1

美胚控场 2024-10-06 20:15:06

如果它们共享顶级域(例如 foo.example.combar.example.com),那么您可以设置 document.domain = 'example. com';放宽同源限制

如果您仅支持 HTML5 浏览器,则可以使用 postMessage() 正是用于跨域通信。

其他选项是 JSONP (跨域

If they share top-level domain (e.g. foo.example.com and bar.example.com), then you can set document.domain = 'example.com'; to relax same-origin restriction.

If you support only HTML5 browsers, then there's postMessage() exactly for cross-domain communication.

Other options are JSONP (fancy name for a cross-domain <script> tag) and proxying of XmlHttpRequest via the server on each domain.

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