...

View Full Version : 1 menu code - multiple pages



drizzamed
01-23-2009, 08:05 PM
I would like some help on what the proper way is of having 1 javascript (menu) and using that same menu on every page for the site. For ease of editing one script and having it reflect on all the other menus so I don't have to edit each menu to reflect any changes. So I guess a source and then everything feeds from that source.

You can see my test page and view the source code at http://www.chippewafallskiwanis.org/test

I'm beginning not to have much fun and starting to regret saying I would be happy to help the local club out!

Thanks in advance.

jmrker
01-24-2009, 05:34 AM
Set-up the desired menu in an external JS file.
Then on each HTML page where the menu is to occur, call the script with


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

Be sure to put only JS code into the external file.

ubh
01-24-2009, 06:12 AM
I cant think of any reason why you would want to make a site's main menu be that of one generated by JavaScript... makes me shutter every time.

Lots of people still browse the net with JavaScript turned off and I would never want to have my main navigation to my site discarded to people who dont have it turned on. Second I cant remember what it is but for some reason I think its bad for SEO purposes too. A search engine's crawlers can't understand JavaScript and tent to skip over and hault the crawling process if confronted by JavaScript.

So with that said I would see if your web server supports a server side language such as PHP and learn about php's "include" feature. Make one JavaScript free menu such as a pure CSS menu and save it out as a .php file on your web server. In each page you want to include this single php file you use the php's include function. Then any updating to this single php page (menu) it will cascade down the whole site just the same.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum