...

View Full Version : Javascript include for navigation



Grant Palin
11-19-2002, 03:16 AM
I have a site which divides the pages between two tables: one for navigation links, and one for content. Instead of having to change the links on every_single_page when I make changes, can I just include a javascript file at the right spot? I mean, I've seen how you can include a javascript file using <link href="script.js">. Can that be done for site navigation links?

x_goose_x
11-19-2002, 05:07 AM
yes if you use document.write()

or you could try using frames.

Grant Palin
11-19-2002, 05:10 AM
That was my first thought actually, but there's a problem with that. I have to do this personal website for school, and my teacher says that I cannot use frames. So, I'm looking into alternatives.

Vladdy
11-19-2002, 05:28 AM
I just finished this university department web site that uses the Javascript - generated navigation menu.
http://server.ime.uri.edu
See if that gives you enough ideas....

realisis
11-19-2002, 11:57 AM
your thread title uses the word "include" so I was surprised to find you haven't considered Server-Side Includes (SSI).

<!--#include virtual="path_to_file.html"-->

And unlike javascript, you don't have to worry about what will happen if the visitor has JS turned off.

Grant Palin
11-20-2002, 12:12 AM
But to use SSI, your server has to support it, right? That's a limitation of it's own.

Grant Palin
11-20-2002, 11:26 PM
What are the pors and cons of SSI versus Javascript includes? Are there any good SSI tutorials or references that cover more on SSI?

whammy
11-21-2002, 03:14 AM
Well, I think that's something you need to research a bit if you don't yet understand the difference. There are a lot of posts here regarding this subject, not to mention google. ;)

If your server supports server-side includes, you can simply include another HTML file by using the syntax above (assuming you have named your page with an ".shtml" extension).

External javascripts are a different beast, as you will have to include them on the page like so:

<script type="text/javascript" src="myJSfile.js"></script>

And then reference them as you would a javascript that was typed into the source code.

whammy
11-21-2002, 03:15 AM
SSI is better than javascript includes though - since if your server supports SSI, the HTML will always be included.

Javascript includes assume that the client has javascript enabled.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum