开发者

Is any way to load entire web-page from different domain to my page?

开发者 https://www.devze.com 2023-03-26 18:37 出处:网络
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.

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 开发者_StackOverflow社区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


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:

<?php
    if(isset($_GET['url']))
        echo file_get_contents($_GET['url']);
?>

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.


Think of it this way, in your server side e.g. with php and curl download the page from the other domain and then ajax them into your webpage with jQuery. It's like proxying pages, but now they are in you server and you can avoid granting crossdomain rules.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号