I have a menu that needs changing on all my documents and it will take really long... I code with HTML and I need to know a code that will include the file with the menu so that this is the last time I have to do it manually. Does anybody know the code??
To do this you have to use an iframe in your pages and have a html file with your menu in it. This is the code for an iframe: <iframe src="yourmenu.html" width="100%" height="50" border="0"> </iframe> Code (markup): src="xxx.html": This is the link to your menu file width="100%": This is the width of your frame. You can use a value in pixels instead of procent too height="50": See width border="0": This is the thickness of the border around the iframe. Use 0 for no border.
You could use an iframe like what r0bin suggests, but if you do, there are a few things you should know. The links in the file that you include in your iframe need to have the target set to parent. <a target="_parent" href="pageyouarelinkingto.html">Anchor Text</a> Code (markup): And setting the border to 0 won't get rid of the border completely. You have to set frame-border="0" You should also set scrolling=no to hide the scroll bar. But what I would use instead of an iframe is a txt file, and server side include. That way if you want to do something like change the width of the menu, you won't have to do this in all of your pages. To do a server side include in php, just add the following. <?include 'filename.txt'?> Code (markup): The rest of your page can stay the same html, but you will have to add the extension .php to your files instead of .html. What the iframe does is just make a little box with a set hight and set width where you can show the contents of another page, where as a server side include will actually insert the contents of the txt file into that place on your page.
Ack!!! Absolutely do not use (i)frames for this. The proper way to include a menu or other bit in a page is to use includes. Web servers have server side includes as do all server side programming languages. An include is, at its core, a paste operation. You have a snippet of code, and the include tells the server to paste it into the document wherever you tell it to do so. For example, you have a file menu.inc (you could call it whatever you like—I like to use the .inc extension to indicate it's not a complete document): <ul> <li>menu item</li> <li>menu item</li> <li>menu item</li> <li>menu item</li> <li>menu item</li> </ul> Code (markup): Now in any page the menu should appear, do this at the appropriate spot in the document: <!--#include virtual="menu.inc" --> or for PHP, <?php include 'menu.inc' ?> Code (markup): Addresses are relative. Change the menu.inc file, and all pages using that file reflect the change. Apache's SSI tutorial is ref'd above, rtfm for your favorite language. cheers, gary
Watch out with including. If you don't have the right permissions on your server hackers can use your include script to include shells and hack your site.
Second the do not use iframes. Many places now block iframes and they have gotten a bad rep. Use php create a file such as menu.php and load all the menu files in there. Then a simple where you want the menu to show. It makes changing things of all your pages very easy once set up.