有什么方法可以将整个网页从不同的域加载到我的页面吗?
我想制作一个页面,可以将来自不同域的其他页面加载到其中。加载的页面应该像它们本身一样工作。
原因是为它们添加额外的功能。
我尝试过使用 JavaScript 和 iframe 来做到这一点,但我受到同源策略的限制。现在我正在考虑 Java Applets/JavaFX/Apache Pivot。我读到,通过数字签名,他们能够建立连接来加载页面。
我的页面还应该从加载的页面获取一些信息(标题、图标等)。
我这样看对吗?还是仍然无法做到?在其他情况下哪种技术是更好的选择?
PS感谢您的帮助
I would like to make a page where I can load other pages from different domains into it. Loaded pages should work as they work by themselves.
The reason is adding extra functionality to them.
I have tried to do it with JavaScript and iframes, but I was limited by the Same origin policy. Now I'm thinking about Java Applets/JavaFX/Apache Pivot. I have read that with digital signatures they are able to establish a connection to load a page.
My page should also take some information (title, favicon, etc) from the loaded page.
Am I right looking in this way? Or it's still impossible to do? In other case which technology is a better choice?
P.S. Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用代理将内容传送到您的域,然后您可以按照您想要的方式操作页面(使用 iframe 或 ajax)。
假设您创建了一个名为
proxy.php
的 php 代理:iframe 的 src 不应指向外部页面 (
),但是到您的代理将该页面的内容传递给您:
.
这将是管理您的任务的一种简单方法,尽管您不能通过这种方式真正复制其他站点...您仍然需要考虑 cookie、标头和其他与会话相关的变量。
You can try to use a proxy that will deliver the content to your domain, and then you can manipulate the pages anyway you want (with iframes or ajax).
Let's say you make a php proxy named
proxy.php
:The iframe's src should not be pointed to the external page (
<iframe src="somedomain.com/somepage" />
), but to your proxy that delivers the contents of that page to you :<iframe src="proxy.php?url=somedomain.com/somepage" />
.This would be an easy way to manage your task, although you cannot really copy other sites this way... you still need to take into consideration cookies, headers and other session related variables.
这样想,在您的服务器端,例如使用
php
和curl
从其他域下载页面,然后使用jQuery
ajax 将它们添加到您的网页中代码>.这就像代理页面,但现在它们位于您的服务器中,您可以避免授予跨域规则。Think of it this way, in your server side e.g. with
php
andcurl
download the page from the other domain and then ajax them into your webpage withjQuery
. It's like proxying pages, but now they are in you server and you can avoid granting crossdomain rules.