Forum Moderators: open
but i was wondering, is it possible to include a separate part of html as an include, like you can with javascript where you have a script source in another file?
i'm trying to make a menu system that is editable from just one file and then refered to in the html of all the pages in the site so i only have to edit it once for the whole site to be updated.
thanks
To address your question:
What you want to do can be achieved in one of three (popular) ways, using:
1) Frames
2) Server Side Includes
3) PHP Includes (very similar to 2)
Can you tell us if your webhost allows you to use PHP or SSI?
No.1 involves only html but can get messy/complicated.
I'm not going to advocate it!
No.2 involves giving all your files the extension .shtml and putting the following snippet of code where your menu code normally goes:
<!--#include virtual="menu.inc" --> No.3 involves giving all your files the extension .php
and putting the following snippet of code into your files in the appropriate place:
<?php
include("menu.inc");
?>
Note that changing the extensions is not strictly necessary it depends on your particular web server's configuration but the above is common.
[edited by: mm1220 at 1:09 pm (utc) on Dec. 4, 2004]
An <iframe> will insert the contents of an external file into your HTML document. It is cross-browser compatible and does not rely on JavaScript or server support services like SSI or PHP. <iframe>s are not subject to most of the issues that people associate with conventional frames because they are very different concepts. Check it out on any HTML tutorial site and I'm sure you'll find uses for it. Good luck!