Javascript Side Navigation

design

#1

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


#2

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 http://en.wikipedia.org/wiki/Server_Side_Includes

Hope this helps!


#3

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=http://dreamhost.com/r.cgi?296804/signup|DH3]Sign Up NOW[/url] or [url=http://patrtan.dreamhosters.com/promo.php]More Codes Here[/url][/i]

#4

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.


#5

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


#6

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: www.sewickleygo.com)


#7

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