Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding two HTML documents into one page

Tags:

html

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.

like image 736
Dave Avatar asked Sep 05 '26 11:09

Dave


2 Answers

You mean like this:

<html>
<head>
</head>
<frameset cols="30%,*">
<frame src="page01.html">
<frame src="page02.html">
</frameset>
</html>
like image 129
SIFE Avatar answered Sep 08 '26 04:09

SIFE


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.

like image 21
Amadan Avatar answered Sep 08 '26 03:09

Amadan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!