Here's an example using PHP:
PHP Code:
<?php include('../path/to/my/menu.htm'); ?>
That will take the contents of the included page and basically "copy and paste" them into the current page, each time it loads. So just change the menu.htm page and it will update all of them.
Of course if you only want this on some pages then just put that code on the pages where you want the menu-- no reason it would appear on any others.
Here are a few notes:
1. Any pages that use that PHP code to include the menu must have a .php extension. (The menu page can be .htm or .php.) .php is the PHP extension and it means that PHP code will be processed first then it will be sent to the browser as HTML (just like a .htm file). [You can set your server to parse .htm files as .php files if you really want, but it's complicated. And not usually that helpful.]
2. If that menu requires any external Javascript or CSS files, you will need to deal with those on every page as well. This is why templating might be a good idea, but that's not easy for your first project using PHP. The simplest answer is to create two files to include, one called "menu.htm" and another called "menuhead.htm". In the first, write the HTML as you want it in the body of your page and include that page into the body of any page where you want the menu. Then in the menuhead page write the tags to use the .js and .css files, then include that into the <head> section of any page where you want to use the menu. As long as each page includes both, everything should be synchronized.
3. For any links or shared external files, use absolute paths, not local paths:
Local path: mypage.htm or ../mypage.htm
Absolute path: http://my site.com/mypage.htm
Short absolute path: /mypage.htm [This is a good trick: using the first slash only you use the base of your current domain, but it's less to type.]
4. To use PHP you must have it installed/enabled on your server. You could do this same method (changing a few things here and there, but the same ideas) with ASP.NET, CGI, SSI (server side includes-- perhaps the easiest), or any other available serverside language that allows 'including' files or an equivalent.
I hope that helps you get started.
If all of this sounds too complicated you could use iframes. Not a great solution, but certainly the easiest.
Bookmarks