?
Solved

common html part

Posted on 2003-03-06
7
Medium Priority
?
169 Views
Last Modified: 2013-12-16
Hi Expert

I'm writing several HTML pages. Each page has a part of  code which is same for all the pages. I would like to put this code to a separate file and include it in each page. So, any change on this common file will be reflect on all these pages.

What's the good way to do it?

Thanks
0
Comment
Question by:zouwei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:dreammh
ID: 8086036
You can write them in a js file and then include them in every page.

e.g. you write the code in the js file and name it header.js

so in ur code u can put:

<script src="header.js"></script>

They are only for javascript format but you can easily use the document.write() to write out html.
0
 
LVL 2

Expert Comment

by:Kovis
ID: 8086199
Well if you have the possibility to use ASP or some other server side language, then do it server side. You can include lots of js-files with HTML in them to your page, but it really isn't the wisest or fastest way. What if the user has disabled client scripting? Your page never even renders properly.

When you do things in server side, then you have total control over what your page renders out. You can even do browser sniffer and render the page differently for every browser.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 300 total points
ID: 8086223

It depends on your web server.
The server has to support SSI.
This stands for ServerSideIncludes.
And this is the tag to be used:
 <!--#include file="/includes/common.shtml"-->

Here some description:
http://hoohoo.ncsa.uiuc.edu/docs/tutorials/includes.html


If your server has no SSI enabled, then you could try this:
<iframe src="="/includes/common.html"></iframe>

Or this:
<OBJECT DATA="http://www.experts-exchange.com" HEIGHT="400" WIDTH="500"></OBJECT>


Good luck,
Zvonko

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:dorward
ID: 8087950
0
 

Expert Comment

by:webmanager
ID: 8089544
I've run into a similar issue.  You can put the code into a .js and run it externally, but then you'll be cutting off the population who use non js capable browsers.  This isn't a problem in most circumstances, but might be depending on your situation.

What I've done in those circumstances, is create a template file with the code 100%.  Then use that template to create all the pages in the site.

I've then used Allaire Homesite 4 (now Macromedia Homesite 5, or this functionality is also in Macromedia Dreamweaver MX) to search and replace multiple lines of code through multiple files, directories, etc.  It works quite well.  The downside is that you'll have to FTP all the pages back up to the server, which isn't usually a big deal unless you have a large site you're working with.
0
 
LVL 17

Expert Comment

by:dorward
ID: 8089874
Note that search engines are part of the population which doesn't handle JavaScript, so if you have your navigation included with JS then they won't be able to follow the links in it (and therefore won't index the pages behind it)
0
 

Author Comment

by:zouwei
ID: 8103340
Thanks. I solve this issue using asp include.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses

765 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