htmlhtml-frames

What the right structure to display html plus a source page?


I want to display a source web page with some information about it above the page in HTML. I initially though of doing this with frames, but as far as I can tell a frame can only display an HTML src, not raw html. To b e clear, if the frame tag was allowed to enclose raw html, I would want to do something like

<frameset rows="200,2*">
   <frame name="info>
      <h3>Stack Overflow</h3>
      <p>A site for programming questions</p>
  </frame>
  <frame name="site" src="http://stackoverflow.com">
</frameset>

What is the right way to do this?


Solution

  • You can use something like this:

    In your HTML page, use:

    <iframe src="get.php?url=http://google.com"></iframe>
    

    And then, you create a php (or your server language) page:

    <?php
    header('Content-Type: text/plain; charset=utf-8');
    echo file_get_contents($_GET['url']);
    ?>
    

    This way you can load any webpage, and you even can change it with javascript without reloading your html page. But be aware that everybody can get any webpage using your get.php page.