atw: SEC: UNCLASS Re: How to include another file in an HTML page?

Hedley

You can include one file in another using IFRAMEs, as Stuart suggests.
But this seems to be regarded as unsatisfactory by many people, because
the IFRAME tag isn't so well supported and I think may cause problems
printing. Generally, including one file in another is done using Server
Side Includes (or SSIs), which involve server-side programming -
something that I can't tell you anything about. 

However, if the example you describe is really all you need, you can do
it quite simply using (client-side) JavaScript. (As Elizabeth says, you
can use the 'document.write' command.)

Since you seem to want to keep the address details in one file but use
it repeatedly in different locations, I'd suggest creating a very simple
JavaScript file consisting of just these lines:

function ContactDetails() {
        document.write('MyName<br />MyStreet</span><br />MyTown<br
/>MyStateAndPostcode<br />MyTelephoneNumber')
}

but with the actual name, street etc in place of MyName, MyStreet etc.
Put these lines into an empty document and save it as text with a name
like 'contact.js', in the same folder as the HTML files in which you
want to include the details. The file contact.js is the file you'll need
to modify when your details change.

Then include these lines in the HTML documents wherever you want your
contact details to appear:

<script language="JavaScript" type="text/javascript"
src="contact.js"></script>
<p>
<script type="text/javascript">
<!--
ContactDetails()
// -->
</script>
</p>

(Strictly speaking, you only need to put the first line once in each
document. But it won't hurt if you just paste all of the above in
wherever you want your contact details to appear.)

This will put the details you want into each document, as a simple
paragraph that'll look like:
MyName
MyStreet
MyTown
MyStateAndPostcode
MyTelephoneNumber  

(but with your values substituted) using the standard font etc.
(Assuming of course that the reader has JavaScript enabled.) If you want
to make it fancier, just put in a few extra tags in your JavaScript
file, inside the string that appears between the quotes after the
document.write.

If your HTML documents aren't all in the same folder, you can't just put
your contact.js into the same folder as them, so you'll need to include
a more detailed reference for the contact.js file. 

And of course you'll need to upload the contact.js file along with the
HTML source files to the web server.

Hope that helps. Feel free to contact me off-line if the explanation
isn't clear.

(Just noted that Peter Bloxsom came up with something similar!)

Howard

----------------------------------
        Howard L. Silcock
         Technical Writer
   Common Services SOE Program
Network Infrastructure Development
      Department of Defence
    Unit 3-4, 25 Napier Close
        Deakin ACT 2600           
        (02) 626 58828  
----------------------------------




**************************************************
To post a message to austechwriter, send the message to 
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to 
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with 
"unsubscribe" in the Subject field.

To search the austechwriter archives, go to 
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to 
austechwriter-admins@xxxxxxxxxxxxx
**************************************************

Other related posts: