RE: Client-side HTML Includes

by "Campbell, Rebecca" <Rebecca.Campbell(at)converg.com>

 Date:  Tue, 23 May 2000 18:13:57 -0600
 To:  "'Andrew Sturmey'" <andrew.sturmey(at)deverill.co.uk>,
"'hwg-techniques(at)mail.hwg.org'" <hwg-techniques(at)mail.hwg.org>
  todo: View Thread, Original
use javascript...  just have functions called getHeader() and getFooter() or
whatever and define them to document.write the html you want displayed.  if
you keep the javascript in a separate file and link to it from your pages,
it works pretty well.

example:

<html>
<head>
<script language="javascript" src="myjs.js"></script>
</head>
<body>
  getHeader();

  <h1>This is my page la la la</h1>

  getFooter();
</body>
</html>

in the file myjs.js, you would have:

function getHeader() {
  document.write('<img src="banner.gif"><br>I like Javascript');
}

function getFooter() {
  document.write('bottom of the page');
}

hth,
rebecca
http://www.nerdygirl.com

-----Original Message-----
From: Andrew Sturmey [mailto:andrew.sturmey(at)deverill.co.uk]
Sent: Tuesday, May 23, 2000 3:21 PM
To: 'hwg-techniques(at)mail.hwg.org'
Subject: FW: Client-side HTML Includes


Can anyone assist?

I've been asked to design a site.  Three requirements of it that I'm having
trouble meeting with a single solution:

- It must be really light on bandwidth.
- It has to have a chunk of standard navigational stuff at the top of each
page, and some corporate copyrighty, disclaimery stuff at the bottom of each
page.
- It may not use frames in any capacity.

Ordinarily I'd either put the non-changing stuff in alternate frames to the
browsable stuff, or I'd use server-side includes to churn out the same bits
at the top and bottom of each page.

Since server-side includes are a no go area as they'd have to be
retransmitted in each page, I thought a cachable client side include would
be in order.  Never having done this before I looked to the official html
specification for answers.

The obvious way to do this looked like using an <OBJECT> tag to include the
same two files in each page, but when I did this, I got horrible IFRAMEish
looking bits appear *groan*.

Any ideas on how I can just include chunks of other pages in a page without
having to have kludgy looking bits?

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.