I\'m looking to put only a small part of a website into an iframe. How would I do this? Usually when I set up a iframe for a website (lets say yahoo) it gets the whole website..
An gives you a complete window to work with. The most direct way to do what you want is to have your server give you a complete page that only contains the fragment you want to show.
As an alternative, you could just use a simple There may be other things you need to do, and a significant difference is that the content will become part of the main page instead of being segregated into a separate window. You won't be able to manipulate the URL to get only a portion of the page. So what you'll want to do is grab the page contents via the server-side language of your choice and then parse the HTML. From there you can grab the specific DIV you are looking for and then print that out to your screen. You could also use to remove unwanted content. With PHP you could use Here's the basic idea. This is untested but should point you in the right direction:load
function to load the whole page and pluck out just the section you want:
$('#target-div').load('http://www.yahoo.com');
file_get_contents()
to read the file you want to parse and then use DOMDocument
to parse it and grab the DIV you want.$page = file_get_contents('http://touch.facebook.com');
$doc = new DOMDocument();
$doc->loadHTML($page);
$divs = $doc->getElementsByTagName('div');
foreach($divs as $div) {
// Loop through the DIVs looking for one withan id of "content"
// Then echo out its contents (pardon the pun)
if ($div->getAttribute('id') === 'content') {
echo $div->nodeValue;
}
}