Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    1 menu code - multiple pages

    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.

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,084
    Thanks
    38
    Thanked 498 Times in 492 Posts
    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
    Code:
    <script type="text/javascript" src="CommonMenu.js"></script>
    Be sure to put only JS code into the external file.

  • #3
    ubh
    ubh is offline
    Regular Coder ubh's Avatar
    Join Date
    Apr 2008
    Location
    Portland, Oregon U.S.A.
    Posts
    443
    Thanks
    108
    Thanked 15 Times in 14 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •