Solved

'Including' an HTML document

Posted on 1998-08-06
2
527 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
ID: 1845100
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
ID: 1845101
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to dynamically set the form action using jQuery.

867 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

21 Experts available now in Live!

Get 1:1 Help Now