navigational menu

liunx

Guest
i have a navigational menu which i want it to be stationary in all my pages. Is there a way that i will write the code once and then refer to it instead of typing the same code on every page. However, please note that i dont want to use frames in my pages.<br />
<br />
thanks!<!--content-->You can make a script that will generate the menu and put it in a .js file. Then use the <SCRIPT> tag to include it in the page:<br />
<br />
<script language="JavaScript" type="text/javascript" src=http://www.webdeveloper.com/forum/archive/index.php/"mymenu.js"></script><br />
<br />
The file "mymenu.js" cannot contain any HTML except in string literals.<br />
<br />
The other way is to use server-side includes, but I don't know much about that. Perhaps someone else can help.<!--content-->Using JavaScript here will fail one out of ten times (<!-- m --><a class="postlink" href="http://www.thecounter.com/stats/2002/November/javas.php">http://www.thecounter.com/stats/2002/November/javas.php</a><!-- m -->) and is therefore very, very bad. And because people with certain disabilities cannot use JavaScript it is also ilegal in cerain places. Use server side includes. Thare are lots of diferent kinds so contact your server people to find out what is available to you.<!--content-->I'm pretty sure you can do this using SHTML. I don't know the specifics but you would do something like this: create a page like index.shtml. Then in that page you would have something like this:<br />
------------------------------------<br />
<!--#include file="top.txt"--><br />
<h2>Welcome to my site</h2><br />
<!--#include file="bottom.txt"--><br />
----------------------------------<br />
Where top.txt is contains your top border and is a regular web page (with a heading, body, etc.). <br />
<br />
This may not be totally correct, but I know there's a lot of good info out there on SHTML and it's easy to do.<!--content-->i would have thought that your best bet would be to use frames - put the navigation into one frame, and then have the links change in the main frame. if you dont know how to use frames then head over to HTML goodies (<!-- m --><a class="postlink" href="http://www.htmlgoodies.com">http://www.htmlgoodies.com</a><!-- m -->) for a tutorial. (Yes i know that it will probably teach him all the wrong conventions, but it will be a darn sight easier to learn than studying the W3C conventions...)<br />
<br />
Once you've got the basics, head to the W3C conventions site (check any post by Stefan for a link) to clear up all the bad practices you've just learnt, and then you should be fine.<!--content-->It's far easier to learn the correct method first time rather than go to a tutorial, which teaches you bad practice and the having to correct your ways at a latter date.<br />
<br />
Though the W3C mainly produces Technical Recommendations and supporting examples rather than actual step-by-step tutorials.<br />
<br />
Yes, you can use Server Side Includes assuming your web server is configured for SSI them most are.<br />
<br />
Basically you'd write something like: <!--#include file="lorem.txt" --> within your main HTML pages.<br />
<br />
Within the lorem.txt file you'd add the HTML you'd like to insert into your chosen file to the and when Download <!--more-->ed from the server it will include pull the data from the lorem.txt file and insert it into your web page where you typed the SSI command..<!--content-->I've been reading through this thread and I tried Robert Well****'s suggestion on my own site, and it seems to work just fine. Just one question: In Robert's example the included file is called lorem.txt. Does it matter which file extension you use -- e.g. does .txt or .html make any difference?<!--content-->No, you can include .txt, .htm, .html, .php, etc.<!--content-->
 
Back
Top