Javascript Side Navigation



I am a newbie (so please talk simple – smile).
I would like to develop a side navigation javascript so that when I update the side navigation to add a new element, I only have to edit on file.
Any suggestions or links?
Thank you folks


Hi Shayman!

If you want to create a navigation area that only requires you to update one file there are a couple ways to do it. My preferred choice is to use PHP’s include() or require() functions. I like this way because most sites are make are PHP based already.

Another alternative is that you could use a Server Side Include (SSI). This is will allow you to put insert content into an HTML page from external files. For more information on SSI’s check out

Hope this helps!


PHP and Server Side Include and simply solve the problem.

If you want to use javascript, here are the steps:

  1. write this code in your main page to include a javascript file
2. in yourjavascriptfile.js, write codes like document.write('Link 1'); [i] $50 off and 3 free domains with code: [color=#CC0000]DH3[/color] [url=|DH3]Sign Up NOW[/url] or [url=]More Codes Here[/url][/i]


Oh how I loathe document.write(). innerHTML is a much more well behaved interface, I think, and it also offers a lot more flexibility.

Anyway, I will third the suggestion that PHP, SSI, or some other server-side scripting is the best solution. JavaScript for this poses a fundamental usability problem for users who do not have JavaScript available in their browsers and doing this server-side avoids that potential problem entirely.


You are right.

I always use PHP functions to include an external file. But recently I was forced to use Server Side Include because PHP is not supported in that server. And then, I was forced to use Javascript because Server Side Include is also not supported in another server. :frowning:

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


Thanks folks,
Now I have two problems:

  1. Should I use PHP or SSI?
  2. I’d rather use SSI, I think, but I can’t figure out how to do the .htaccess.txt – the wiki article did not explain it well for me. Any links to learning SSI would be deeply appreciated.

Again, I am a complete newbie (my one site:


PHP is enabled by default. To use PHP require function, simply rename your file to .php and write

<?php require("filename.html"); ?> or <?php require("filename.php"); ?>

I’m not sure whether SSI is enabled by default or not. If not, you can add this

AddType text/html html .shtml
AddHandler server-parsed html .shtml

in your htaccess file to enable it.

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here