Dave Dave - 2 months ago 9
HTML Question

Embedding two HTML documents into one page

I want to output two HTML documents, wrapped inside of an HTML document

Is it possible to do something like this with HTML?

<html>
<head></head>
<body>
<frameset>
<frame>
<html>
<head></head>
<body>First page here</body>
</html>
</frame>
<frame>
<html>
<head></head>
<body>Second page here</body>
</html>
</frame>
</body>
</html>


It doesn't have to be frames, but I only want to hit the server once, so linking to a document with src attribute is out, it has to be inline.

Answer

Not possible. Neither iframe nor frame is inline. The best for your scenario would be to extract the body tag content, and insert it into a div. CSS would be a problem, though - there'd have to be some processing on it so it would be restricted to just half the page. Something like this:

<html>
  <head>
    <title>Combined</title>
  </head>
  <body>
    <div id="page1">
      First page here
    </div>
    <div id="page2">
      Second page here
    </div>
  </body>
</html>

CSS transformation: body -> #page1 (or #page2), #id -> #id, anything else X -> #page1 X.

Using iframes is definitely easier; and if the server is well-configured, it probably doesn't even require a separate connection.

BTW: Your suggestion will probably render, but AFAIK it's non-standard (browsers guessing what you want, instead going by the specification, something browsers have gotten used to having to do); and there's still the problem of CSS.

Comments