如何读取加载来自​​另一个域中的网页的iframe的DOM? [英] How to read DOM of the iframe loaded with a page from another domain?

查看:221
本文介绍了如何读取加载来自​​另一个域中的网页的iframe的DOM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有访问文档的DOM从父文档一个IFRAME如果iframe的文档是另一个域中的方法吗?我可以很容易地访问它,如果双方父母和子女的页面都在同一个域名,但我需要能够做到这一点时,他们在不同的领域。

Is there a way to access the DOM of the document in an iframe from parent doc if the doc in the iframe is on another domain? I can easily access it if both parent and child pages are on the same domain, but I need to be able to do that when they are on different domains.

如果没有,也许有一些其他的方式来阅读一个iframe的内容(其中一个考虑是创建一个ActiveX控件,因为这将是唯一的企业内部使用,但我会preFER它是跨-browser兼容)?

If not, maybe there is some other way to READ the contents of an iframe (one consideration was to create an ActiveX control, since this would be for internal corporate use only, but I would prefer it to be cross-browser compatible)?

推荐答案

不是真的。这对于安全至关重要 - 否则,你可以打开我的网上银行网站或网络邮箱和惹它

Not really. This is essential for security – otherwise you could open my online banking site or webmail and mess with it.

您可以放宽限制,通过设置 document.domain的<的一点/ code>,但仍顶级域名必须是相同的。

You can loosen restriction a bit by setting document.domain, but still top level domain must be the same.

您可以解决此限制由代理通过自己的服务器请求(但不要忘记,以确保它,否则S [CP] ammers可能会滥用它)

You can work around this limitation by proxying requests via your own server (but don't forget to secure it, otherwise s[cp]ammers may abuse it)

my.example.com/proxy?url=otherdomain.com/page

这篇关于如何读取加载来自​​另一个域中的网页的iframe的DOM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆