How to display other sites content in our sites with out using iframe? Is it possible to load one sites file details in our site with out using the iframe. any body knows the solution please help me with a sample code?
The way I have achieve this in the past is as follows
<?php
$handle = fopen("http://someurl", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
echo "<div>Your Content</div>";
echo "<div>";
print($contents);
echo "</div>";
echo "<div>More of your contents";
?>
It is possible and quite easy with YQL.
The Yahoo! Query Language is an expressive SQL-like language that lets you query, filter, and join data across Web services. With YQL, developers can access and shape data across the Internet through one simple language, eliminating the need to learn how to call different APIs.
jQuery should be able to do this (I'm assuming you're using jQuery since you've tagged the question with it). You should look at the documentation on the .load() method as that has an excellent example in there
Edit: As Nick points out below, this will only work for pages on the originating site due to the same origin policy in javascript
You cannot use Ajax due to the Same Origin policy. There are two ways to circumvent this.
Use a proxy - As Gazler said, you can create a proxy script in PHP to download the file. Call the file proxy script from your javascript.
Use JSONP - You can use JSONP for cross domain communication. Make sure you read the cautionary note
You can achieve it with the code below. Two notes though:
1) I'm not sure this works with IE
2) Heed the advice put out by @Paul_Tomblin and @Codemwnci about getting permission to display a different site's content.
The html part is:
<object id="external-page" type="text/html" data="" >
</object>
The javascript part in jquery is:
$("#external-page").attr("data", "http://foreign-site.net/foreign-page.html");