Loading an external website in a DIV

Hello everyone,

What I would like to do is load an external website within a DIV on one of my web pages.

The problem is that my web pages already contain a <head>.

The basics of what I want to do is:


<?
require("header.php");
// load external webpage here
// e.g. Amazon homepage
require("footer.php");
?>

If anyone has any suggestions ort solutions, please can you help?

Thank you very much for your time.

The question is why you’d want to do this anyway, but:

<div><?php echo file_get_contents('webpage'); ?></div>

It won’t be pretty.

Thank you for your quick reply.

You say that it won’t be pretty… why is that exactly?

Thanks

well, websites are designed for a certain window size etc. They also contain internal links and URLs, which would be a pain to work.

What would you use this for anyway?

Oh yes, never thought about the links and urls within the page!

I want to redirect people to various websites but keep the header on the page at the same time.

Is there a way of using a frame or iframe that would allow the relative urls to work properly?

Or would it be better to bypass the entire html page, replacing any links with the webpage name prefix? I hope this isn’t the only solution (I am looking for a quick fix for this!).

Thank you again for your reply.

An iFrame is your best option.

Nice one.

I used an iframe, plus a bit of javascript to get a good height and it was a success.

Why use javascript - why not just use CSS?

JS should never be your first resort to a problem.

I have just come along a problem and I think I know why but have no solution.

The iframe works but the height sometimes remains too short (but only for dynamic websites). Do you think there is a method that resizes the iframe height correctly (after the inner website has loaded?) but doesn’t cause too many problems?

With regards to using CSS, that sounds like a better idea - I am only using JavaScript now to get a quick result! I will try a CSS solution now anyway and that may even bypass the height problem I am getting.

Thanks

Any chance you could offer the iframe code you used? I’m trying to do the same thing. The page I’m loading is very scalable so it should not present any problems and it has no external links. I’m trying to integrate a dot mac gallery. Apple doesn’t offer any CSS customizations of their dot mac galleries so my thought was drop a header and footer above and below so I could just wrap the gallery right into the design of the page. Thanks for your help.

This is an interesting problem. Post this question in the JavaScript forum, and I’ll work on it. :slight_smile:

Thanks everyone! file_get_contents() done the trick! Thanks! Thanks! Thanks!