Click to See Complete Forum and Search --> : How do I include an html file within html?


alank2
09-28-2007, 02:13 PM
Hi,

Lets say there is a top menu bar I want to include on every page in a site. Can the content of the top menu bar and its style sheet be put in their own files and included on each page? How do you do this?

Thanks,

Alan

Declan1991
09-28-2007, 02:16 PM
Cannot with HTML without using an iFrame which I don't like. You need to use a server side language.

alank2
09-28-2007, 02:20 PM
Hi,

Is there a common way to do this?

I could repeat the top menu on multiple pages, but then it would be a pain if/when I have to change them...

What is a common SSL, forgive me as I am very new at this...

Thanks,

Alan

harumph
09-28-2007, 02:32 PM
You can create a Javascript function that will write what you need on each page by simply calling the function. That's assuming you don't mind using Javascript to see it. You would create a .js file that you would initialize on each page and place your function after the .js file.

Like this:


<script type="text/javascript" src="menustuff.js">

<script language="JavaScript">
<!--
ShowMenu();
//-->
</script>





Declan is referring to include files. Both PHP & ASP use include files, but the end result is [basically] the same. I prefer server-side includes, myself, but if you're running straight HTML, Javascript works.

LJK
09-28-2007, 05:06 PM
Hi -
I'd recommend .php - if your server's running it - for the menu.
If not, then server-side includes [SSI's] are worth looking into...

CSS is easily made external with a filename.css linked to each page it's
needed on in the <head>:
<link rel="stylesheet" type="text/css" href="filename.css" media="screen" />

Good luck,
El

felgall
09-28-2007, 05:33 PM
Check on what server side languages your hosting supports and use one of those.

Whatever you do, don't use frames or JavaScript to do it as that will just lose you a significant percentage of your potential visitors.

dtm32236
09-28-2007, 06:17 PM
felgall is right... don't use frames or JS.

find out if your host supports PHP or ASP, and use on of those methods.

here's a good PHP include tutorial:
http://www.tizag.com/phpT/include.php

Centauri
09-28-2007, 08:18 PM
Also, keep your menu css within the main css file - don't try and link it from the menu include file, as that file must only contain the menu code without any html, head, body tags etc.

sempro
09-30-2007, 02:40 AM
You can't do it. Keeping the js. and frames out of the mix, you will do better in search.

felgall
09-30-2007, 04:32 PM
If your hosting doesn't support PHP or other server side languages then check if it supports server side includes. That will allow you to call HTML to be included into other HTML using special comments and a .shtml extension.