Solved

'Including' an HTML document

Posted on 1998-08-06
2
526 Views
Last Modified: 2013-11-18
I was wondering if it is possible to insert a web page inside another page.  Such as:

File:  MyFooter.htm
HTML:
<HTML>
<HEAD>
<TITLE>None</TITLE>
</HEAD>
<BODY>
Copyright (c) 1998 - Egore
</BODY>
</HTML>

File:  MyHTML.htm
HTML:
<HTML>
<HEAD>
<TITLE>None</TITLE>
</HEAD>
<BODY>
Thank you for visiting this page!<BR>
<BR>
#include "MyFooter.htm";
</BODY>
</HTML>

In the above example, you have two HTML files, one of which 'includes' the other one inside it's body.  Is this possible to do and, if so, how do you do it?

(If you didn't notice, I used a 'C Language' command to include the file in the other file.  This (of course) does not work in HTML...)
0
Comment
Question by:Egore
2 Comments
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
Comment Utility
Yes, it is possible.  Except if you were to include MyFooter.htm, it would have an error since the document would read:
<BR>
<HTML> //include start here
<HEAD>
<TITLE>None</TITLE>
</HEAD>
<BODY>
Copyright (c) 1998 - Egore
</BODY>
</HTML>  //include ends here
</BODY>
</HTML>

And that would be a problem.
To include html files you need a server ability called server side includes (SSI).  This is a really nice feature and makes other things counters work well and maintaining a large site with similar headers and footers easy to do.
So you first need to find out if you service provider allows server side includes.

Then the statement to include a file like this would look like this:
<!--#include virtual="../common/leftlinks.shtml"-->

Another thing about server side includes, is that very often servers that do support them require that any file must have a ".shtml" or ".shtm" extension or whatever the server prefers in order for the file to have an include.  This is so that service would not be slowed down by the server reading in every single file before sending it out.  It will only read in the files which could possibly contain a SSI.

Hope this can work for you!  It's a nice feature if it does.
-Josh
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
There are 2 different include statements:

<!--#include file="relative_path/file.txt"-->

<!--#include virtual="/complete_path/file.txt"-->

The difference is that for the first you have to give a relative path to the current document, the second starts from the root of the server.


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now