SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Separate javascript file

    I there any possible way to set this up so the menu is in a separate javascript file? This way I could just link to the menu on the pages I need it to show up. Go to http://rmv17.topcities.com/ to see the menu. The actual pictures do not show up, but you get the idea when you click on a link and sublinks show up under it. The reason I want to do this is because if I wanted to change something in the menu, I would have to change every page which is time consuming.

    Maybe there is another way to approach it?
    I am open to all suggestions.

  2. #2
    SitePoint Addict psyon's Avatar
    Join Date
    May 2004
    Location
    Cedar Rapids
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just put the javascript in a separate file, name it like menu.js then do
    Code:
    <script language="javascript" src="/menu.js"></script>

  3. #3
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    kansas
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Attached is the menu.js file you recommended me make. Can it have HTML code in it? It is not working. I do not understand javascript real well yet.
    Attached Files Attached Files

  4. #4
    SitePoint Addict psyon's Avatar
    Join Date
    May 2004
    Location
    Cedar Rapids
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can not have HTML directly in the .js file unless you use document.write() to create it.

    In your case you should see if your host provides SSI support. This will allow you to include common files including HTML/CSS/Javascript into your pages


Bookmarks

Posting Permissions

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