473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Placing Common HTML Code In A "Common" File

Hi All

I am working on a site that has a large amount of common html on all its web
pages.
I am looking for a way to place this in a single file so, if changes are
made, I can change this single file and do not have to change each and every
page.
I have the Java scripting in a common .Js file but have not been able to
find a way to do this with my html content.

Anyone ever do this and if so how?
An example would be Great!

Thanks in advance.

Hugs
Sherry
Jul 20 '05 #1
7 5049
Sherry Littletree wrote:
Hi All

I am working on a site that has a large amount of common html on all its web
pages.
I am looking for a way to place this in a single file so, if changes are
made, I can change this single file and do not have to change each and every
page.
I have the Java scripting in a common .Js file but have not been able to
find a way to do this with my html content.

(NB: properly, "javascripting", not "Java scripting", since Java and
javascript are completely separate languages.)
Anyone ever do this and if so how?
An example would be Great!


There are two things that come to my mind right away:

1. Create a javascript file that will (contain functions that)
document.write the common HTML
2. Use Server-Side Includes (SSI) (I use this technique on my intranet)

Each has advantages and disadvantages:

For 1:
Advantages:
A. Requires no special server configuration
B. Lets you deliver the common markup packaged as javascript (and since
you're asking in a javascript group, I assume this is comfortable to you)

Disadvantages:
The material written by javascript will be completely unavailable to
anyone whose browser has js unavailable for any reason (non-existent,
disabled, etc). This seriously breaks your pages.

For 2:
Advantages:
A. Common content can be placed in files that contain HTML that would
otherwise be written into the main HTML file. Any such common HTML file
is designated to be included by a Server-Side Includes directive such as:

<!--#include file="location/file.ext" --> or
<!--#include virtual="url/file.ext" -->

Trivial example:

<html>
<head><title>Trivial SSI Example</title></head>
<body>
<!--#include file="PageHeader.html" -->
<br>
My unique page content
<br>
<!--#include file="PageFooter.html -->
</body>
</html>

PageHeader.html:
<h1>Page Header</h1>

PageFooter.html:
<p>Brought to you by SSI!</p>

Output might be rendered as:

Page Header

My other page content

Brought to you by SSI!
B. No reliance on javascript or other client-side active scripting. All
SSI processing takes place (obviously :-) ) at the server.

Disadvantages:
A. Server must be configured to support Server-Side Includes. Usually
this also means that the main HTML file (i.e., any HTML file containing
SSI directives) must be given a special extension such as ".shtml" (the
customary one, usually read as "server-parsed" HTML).
B. This requires more processing by the web server, which has to read
the content of the file being served, looking for the SSI directives and
following the indicated instructions.

Google for "server-side includes" for additional info. There should be lots.

Regards,

Stephen

Jul 20 '05 #3
Sherry Littletree wrote:
I am working on a site that has a large amount of common html on all its
web pages.
Generally if there is a _large_ amount, its caused by the use of too much
presentational markup. Move your presentation to an external style sheet
file instead.

However, even that will leave some elements you may with to have in common
on each page (such as navigation).
I am looking for a way to place this in a single file so, if changes are
made, I can change this single file and do not have to change each and
every page.


http://www.allmyfaqs.com/faq.pl?Incl...ile_in_another

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #4
Here are two reasons why I cjhose NOT to use SSI as a method to do including
of common modules;
DRAWBACK #!: The use of SSI will make it neartly imposible to do simple
WSYWIG trial and ewrror development work.
DRAWBACK #2: the use of SSI requires the extension of the files to be .shtml
or such. This makes other local authoring tools crap on you, like FrontPage
does.

I chose to use FrontPage as the method to do includes of commong dodules in
a WSYWIG authoring environment on my loac PC where I could test and develop
in a trial_and_error method.

I suspect there are other tools out there besides FrontPage that will do
this without forcing you to rename the extensions and without giving up
local testing. But, I do not know what they are.

"David Dorward" <do*****@yahoo.com> wrote in message
news:bo*******************@news.demon.co.uk...
Sherry Littletree wrote:
I am working on a site that has a large amount of common html on all its
web pages.


Generally if there is a _large_ amount, its caused by the use of too much
presentational markup. Move your presentation to an external style sheet
file instead.

However, even that will leave some elements you may with to have in common
on each page (such as navigation).
I am looking for a way to place this in a single file so, if changes are
made, I can change this single file and do not have to change each and
every page.


http://www.allmyfaqs.com/faq.pl?Incl...ile_in_another

--
David Dorward http://dorward.me.uk/

Jul 20 '05 #5
> DRAWBACK #2: the use of SSI requires the extension of the files to
be .shtml
or such.


The use of .shtml is typically just a server default and where SSIs
are the rule rather than the exception the server can usefully be
directed to parse .html and .htm too. Of course you may not have this
degree of access to the server configuration.

Jul 20 '05 #6
news frontiernet.net wrote:

Maybe you (what a funny name you have BTW) should read:
http://www.allmyfaqs.com/faq.pl?How_to_post
Here are two reasons why I cjhose NOT to use SSI as a method to do
including of common modules;
DRAWBACK #!: The use of SSI will make it neartly imposible to do simple
WSYWIG trial and ewrror development work.
WRONG!

Leaving aside the non-existance of WYSIWYG editors for the web, and the
general poor quality of those editor which claim to be WYSIWYG (but are
really just graphical HTML/CSS generators) -

* If you are doing trial and error development work, you can build your
template and then rip it apart to use for SSI

* A number of generators can emulate SSI during the design process
DRAWBACK #2: the use of SSI requires the extension of the files to be
.shtml or such.


WRONG!

See the second link in the section on SSI at the page:
http://www.allmyfaqs.com/faq.pl?Incl...ile_in_another

.... and of course the server could be configured to use whatever extension
you want (if you don't want to use the XBitHack).

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #7

In article <gF****************@newsread1.news.pas.earthlink.n et>,
"Sherry Littletree" <en******@encryted.org> writes:

I am working on a site that has a large amount of common html on
all its web pages. I am looking for a way to place this in a single
file so, if changes are made, I can change this single file and do
not have to change each and every page. I have the Java scripting
in a common .Js file but have not been able to find a way to do
this with my html content.


PHP is easier to use than SSI and much more powerful. Any server-
side approach is better than javascript because server-side
processing will work even if the client disables active scripting/
javascript.
--

Warren S. Sarle SAS Institute Inc. The opinions expressed here
sa****@unx.sas.com SAS Campus Drive are mine and not necessarily
(919) 677-8000 Cary, NC 27513, USA those of SAS Institute.
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
7
by: William Morris | last post by:
So, what's the prevailing opinion regarding the use of the "CALL" keyword? I'm working with a third-party ASP application, adapting for our system, and the CALL keyword is used everywhere. I've...
5
by: MK | last post by:
Dear friends, I have many HTML files and they all have some common HTML code which is basically bunch of tags which are in all the files. How can I put the common code in one file and then share...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
15
by: David | last post by:
is there some way to make a file (.cs) containing some common C# code classes being loaded on every .aspx page in my web without me having to declare it every time? Something in the config file...
19
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? ...
6
by: Peter | last post by:
Hi I have a number of arrays of longs, from which I need to find a single array which only contains the values which appear in all the original arrays. For example, I could have the three...
3
by: Kong Chun Ho | last post by:
This is my code: index.php // SOME HTML <script language = "javascript" src = "js/common.js"></script> <script language = "javascript" src = "js/register.js"></script> // SOME HTML <body...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.