Let's say my homepage is www.example.com and I want to add a div on it. When people visit my page, I want to show the content from www.google.com within the div.

When visitor clicked any link on www.google.com, it redirects user all within the div. Is it possible to do? If so, how?

2 Answers 2


No, the element you are looking for is an iframe, which does about exactly what you ask.
There's a mayor downsite to this: This is bad for seo, you don't get points for the content in the iframe.
Also, you can't Iframe Google, they don't allow you to. Other sites will work.

The default styling of an iframe is a bit (well, a lot) ugly, so with some basic styling it will look more like the "div-look":

    margin: 0;
    padding: 0;
    border: 1px solid #000; /* Can be [none] too */
    display: block;

Or you could grab the contents of the other page/site and load it into the div.

  1. Dynamic creation (serverside language)
  2. Ajax creation (using javascript and a your serverside language)

You can now use something like PHP's file_get_contents("the-web-page-url") to load the content into a div

  • 1
    serverside will not work, the links found will link to the original page. You could counter this by prefixing all anchors with 'openViaMySite.php?url=example.com`, but that is a disaster waiting to happen (think of the exploit possibilities!)
    – Martijn
    Jun 17, 2014 at 13:40
  • So grab it into a variable and run a preg_match_all on it. Convert all absolute to relative or remove anchors entirely
    – AO_
    Jun 17, 2014 at 13:42
  • Please promise me you dont do that. stackoverflow.com/questions/1732348/…
    – Martijn
    Jun 17, 2014 at 14:04
  • 1
    Yes and a dangerous one, of which the downsides should be mentioned, so any that anyone who might consider this base their solution on the complete picture.
    – Martijn
    Jun 17, 2014 at 14:11
  • 1
    We should also mention that using another website's content is a dangerous one ;)
    – AO_
    Jun 17, 2014 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.