views:

21

answers:

3

Hey all, looking to see if theres a way to easily include external html file inside the body to repeat on every page, for instance: a navigator or something.

Basically if i have to add a menu item or something, i have to go and paste all the code into each page. Or even a way to section parts off in Dreamweaver to update based on a file or something would work i suppose

Ive done it before through JavaScript with document.writes and stuff, but it was very annoying, and probably a terrible way to go about doing so.

thanks for your help!

A: 

That kind of manipulation is generally done using a programming-language on the server-side (Like PHP, for example), that can manipulate files (and other data) to generate an HTML output.

That way, the HTML output sent to the browser can be built from several distinct files (header, content, footer, ...).

Of course, this means not creating the full-pages as HTML files, and, probably, not seing the full page in your editor... But it brings you a lot of power : it allows you to generate pages dynamically, with dynamic content, interacting with a database, external services, ...

Pascal MARTIN
A: 

You have a couple of options:

  • Most html editors have the concept of templates, where you have a fixed page with navigation and footer areas, and you specify the content for each page. THe tool will keep the rest in sync. Look for something like this.
  • IFrame: Don't do that
  • Javascript, like you already talked about.
  • Lightweight server side code, like php

I wrote up a post on doing something like that in php

Tim Hoolihan
A: 

If the external page is local on the web server & you don't use a server side scripting language you can get the web server itself to include content using Server Side Includes.

Alex K.