++HTML Gurus!! I have a question...

Electric Amish

Elite Member
Oct 11, 1999
23,578
1
0
Is there a way to create a single header and/or footer that is displayed on every page of a site? So that if I ever had to make a change I'd only have to make it once instead of on every page??

tia

amish
 

joohang

Lifer
Oct 22, 2000
12,340
1
0


<< You can do it with style sheets I think. It's been a while since I messed around with any of that. >>


Stylesheets can't do that.
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
You can either use asp or php to include the files or you could use the server side includes that apache and I think other web servers have that too.

I only know how to do it in php
<?php include("header.php"); ?>

just look up server side includes.
 

joohang

Lifer
Oct 22, 2000
12,340
1
0


<< Is there a way to create a single header and/or footer that is displayed on every page of a site? So that if I ever had to make a change I'd only have to make it once instead of on every page??

tia

amish
>>


As tedious as it sounds, yes, that's the only way to do it.

You have to rely on the server. i.e. SSI

Or use a program that does a batch edit of your HTML pages.
 

mryellow2

Golden Member
Dec 2, 2000
1,057
0
0
i was under the impression that cascading style sheets were capable of doing that, oh well :confused:
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0


<< i was under the impression that cascading style sheets were capable of doing that, oh well :confused: >>



nah, css is for formatting, not content.
 

Kev

Lifer
Dec 17, 2001
16,367
4
81
if you have dreamweaver, you can create a template for it if you don't have a php or asp server.
 

CyberCowboy

Senior member
Apr 16, 2001
247
0
0
i think the easiest way would be to create two javascript files,
one called header.js and the other footer.js.

inside the files, create your headers and footers,

i.e. document.write('blah.. this is where the code for the header goes');


ANd in your real html pages, just link to those javascript pages. It works, cuz I've done it before.

that would probably be the easiest way without learning asp,etc.

 

gopunk

Lifer
Jul 7, 2001
29,239
2
0


<< i think the easiest way would be to create two javascript files,
one called header.js and the other footer.js.
>>



my knowledge of javascript is minimal, so forgive me if i'm wrong, but wouldn't this result in 3 calls to the server? if speed is a concern, i would go for SSI, since that's server side... though you're right, it is probably the easiest.
 

CyberCowboy

Senior member
Apr 16, 2001
247
0
0
yeah... SSI would be good to use. But the thing is that SSI is not available to everyone, especially those who use free hosts.
 

CyberCowboy

Senior member
Apr 16, 2001
247
0
0
just thought of something else.

you can always use frames.
one frame for the header. Then the middle frame should contain the body of the page. And finally the last frame should contain the header.

This will alleviate the issue of accessing the server so much. The pages might also load a little faster. But remember that not everyone likes frames and you should take into account the screen sizes that people have.

But it should work for all types of servers and there is no javascript or other crap involved. Just pure html.

hope it helps.
 

Pr0Hawk

Platinum Member
Feb 12, 2001
2,607
0
0
That can easily be done with PHP. Make the file, for example header.php. And use the php require code where you want the header to be on ever page. So when you update header.php it will be updated on every page you used
 

Soulflare

Golden Member
Apr 16, 2000
1,801
0
0


<< my knowledge of javascript is minimal, so forgive me if i'm wrong, but wouldn't this result in 3 calls to the server? >>



If the .js files are used on every page, they'll become cached real fast and save the end user
from downloading a ton of HTML. I always use a .js file for mouseover declarations. The only
problem you would run into with .js files is if the moron visiting your site has Javascript turned
off... of course, you could probably just place an HTML-lite text-only header and footer in
between <NOSCRIPT></NOSCRIPT> tags.

SSI and PHP would probably be the cleanest way to do what you want - if your server supports it.