jquery 在 iframe 中选择页面的某些内容

发布于 2024-12-28 09:10:01 字数 688 浏览 3 评论 0原文

我有一个这样的页面:

=========================================
|       PARENT!                         |
|                                       |
|                                       |
|            ===============            |
|            |    iframe   |            |
|            ===============            |
|                                       |
|                                       |
|                                       |
|                                       |
|                                       |
|                                       |
|========================================

是否有任何 jQuery 可以在父窗口中选择某些内容?

这些页面位于不同的域中。

I got a page like this:

=========================================
|       PARENT!                         |
|                                       |
|                                       |
|            ===============            |
|            |    iframe   |            |
|            ===============            |
|                                       |
|                                       |
|                                       |
|                                       |
|                                       |
|                                       |
|========================================

is there any jQuery possible to select something in the parent window?

The pages are in different domains.

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

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

发布评论

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

评论(1

梦一生花开无言 2025-01-04 09:10:01

是的,只要 iframe 与父级位于同一域中,以下操作即可:

$('#idInParent', window.parent.document);

更新: 明确这需要相同的域

Yes, as long as the iframe is in the same domain as the parent the following works:

$('#idInParent', window.parent.document);

Updated: to make clear the fact that this requires same domain

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