Click to See Complete Forum and Search --> : navigational menu


Max^Power
01-08-2003, 04:07 AM
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.

thanks!

gil davis
01-08-2003, 05:50 AM
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:

<script language="JavaScript" type="text/javascript" src="mymenu.js"></script>

The file "mymenu.js" cannot contain any HTML except in string literals.

The other way is to use server-side includes, but I don't know much about that. Perhaps someone else can help.

Charles
01-08-2003, 06:08 AM
Using JavaScript here will fail one out of ten times (http://www.thecounter.com/stats/2002/November/javas.php) 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.

hnhn2020
01-09-2003, 03:13 AM
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:
------------------------------------
<!--#include file="top.txt"-->
<h2>Welcome to my site</h2>
<!--#include file="bottom.txt"-->
----------------------------------
Where top.txt is contains your top border and is a regular web page (with a heading, body, etc.).

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.

jpmoriarty
01-09-2003, 06:01 AM
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 (http://www.htmlgoodies.com) 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...)

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.

Robert Wellock
01-09-2003, 09:59 AM
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.

Though the W3C mainly produces Technical Recommendations and supporting examples rather than actual step-by-step tutorials.

Yes, you can use Server Side Includes assuming your web server is configured for SSI them most are.

Basically you'd write something like: <!--#include file="lorem.txt" --> within your main HTML pages.

Within the lorem.txt file you'd add the HTML you'd like to insert into your chosen file to the and when downloaded 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..

J.Karlsson
01-10-2003, 12:13 PM
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?

pyro
01-10-2003, 12:29 PM
No, you can include .txt, .htm, .html, .php, etc.