Forum Moderators: open
I have a website made up of 12 pages. Each of them has the same layout with the same menu design etc.
Ideally I would like to have the code for the menu etc. in one place which I will call on from all the other pages. This means I will be able to edit the menu, add/remove/alter items etc. in one place instead of having to alter every page in turn.
However, I want to do this without using frames because I don't really like using them in page design.
Can this be done using javascript or some other tools?
Any help is greatly appreciated.
Thanks
D1n1_81
You typically create an html fragment (no <html>, <head> or <body> tags) that contains the common code. Let's call it common.htm
Next, you must arrange for it to be included. This requires an instruction located in a comment. The server must parse the whole file and when it locates the instruction, it inserts the html fragment. This must be enabled on your server. Typically, this is done by using the file extension .shtml but it can be enabled using the .htaccess file (I think) so that can keep your existing file names.
e.g.
<!--#include virtual="/common.htm" -->
Kaled.
If your webhost is running Apache another way is to use Apache's Xbit Hack directive. All my web host providers have it set, you can try it and see if it works on your site.
Xbit allows you to retain the same html file name, you just set the execute bit on the file using chmod. Any html file that has the execute bit set the server will parse it for includes. That way it only spends time on the files that actually have an "include" in the script.
In case I lost you, as an example:
Add an "include" to your index.html file.
Upload the file to the server.
Chmod the file to "744", or "chmod +x index.html"
If the Xbit Hack is working the next time you request index.html you should get it with the include inserted into the script.
If you're on a Windows server it won't work, as you may have guessed.