Include a HTML page in another?

Guv

Guv

Soldato
Joined
24 Oct 2002
Posts
3,257
Location
Warwickshire
I have 2 html pages and want to include 1 on the left side of the other page.

Can it be done?
I've used php before to do this no problem but php isn't an option unfortunately this time.
 
KingAdora said:
I think you can do it by calling your html file .shtml and using this in there


<!--#include FILE="filename.html"-->
Eww. Server side includes. I guess they're a lot less nasty then they were in the early web days (was told to avoid at all costs back then - slow and insecure).
 
Berserker said:
Eww. Server side includes. I guess they're a lot less nasty then they were in the early web days (was told to avoid at all costs back then - slow and insecure).

?

Nothing slow or insecure about them, they're fine to use. I can't imagine how they could possibly slow down a page anywhere near as much as a typical PHP script—how could they?
 
SherberT* said:
WTF? Go back to GD :p

Code:
Client-Side Includes: The iframe Method
If the JavaScript method doesn't meet your needs, consider using the iframe element. This method has the advantage of simplicity, and doesn't require JavaScript. But bear in mind that search engines still don't like it very much. And you are forced to decide in advance exactly how much space your second document will get in your first document.

If the second document is too wide or tall, scrollbars will appear. Depending on your needs, this might be just perfect or a complete deal-breaker.

Using iframe is straightforward. If your second, embedded document is called included.html, just place the following element in the first, "parent" document to display it in an area 450 pixels wide by 400 pixels tall:


<iframe src="included.html" width="450" height="400">
<a href="included.html">Hmm, you are using a very old browser.
Click here to go directly to included content.</a>
</iframe>

Why do I have an ordinary a element inside the iframe element, linking to the document we're trying to embed? Because certain older browsers, and the major search engines, don't support iframe. While very few human beings are still stuck with Netscape 4, almost everyone is using search engines like Google. And we don't want those to ignore our embedded content completely!

The iframe element has additional attributes to control its appearance. In addition to setting width and height, which you must do, you can also decide whether to allow scrolling. In most cases, you'll want to accept the default behavior: displaying scrollbars when the embedded document is too wide or tall for the width and height of the iframe element. But if you absolutely don't want to permit scrolling, even if it prevents the user from seeing all of the embedded document, you can set the scrolling attribute to no instead.

You can also eliminate the visible border around the embedded page by setting the frameborder element to 0. This is important if you want the embedded page to look like a natural part of your page.

Here's the example again with no frame border:


<iframe src="included.html" width="450" height="400" frameborder="0">
<a href="included.html">Hmm, you are using a very old browser.
Click here to go directly to included content.</a>
</iframe>

Might not be great but it still one way of doin it.
 
iFrames can be useful, but doesn't an iframe hold the same kind of disadvantage as with a frame? Poor SEO for example.
 
Last edited:
Yup. Certainly not perfect, and as pointed out elsewhere there's better ways.

PS - SSIs used to be slow due to the way they were implemented in old servers. I remember the days of having to use plugins (similar to PHP) to do them. This is no longer true (I wasn't suggesting it was true - I just have an aversion caused by the early mess).
 
Back
Top Bottom