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 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post

    Javascript include for navigation

    I have a site which divides the pages between two tables: one for navigation links, and one for content. Instead of having to change the links on every_single_page when I make changes, can I just include a javascript file at the right spot? I mean, I've seen how you can include a javascript file using <link href="script.js">. Can that be done for site navigation links?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes if you use document.write()

    or you could try using frames.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    That was my first thought actually, but there's a problem with that. I have to do this personal website for school, and my teacher says that I cannot use frames. So, I'm looking into alternatives.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just finished this university department web site that uses the Javascript - generated navigation menu.
    http://server.ime.uri.edu
    See if that gives you enough ideas....
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    self.location
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    your thread title uses the word "include" so I was surprised to find you haven't considered Server-Side Includes (SSI).

    <!--#include virtual="path_to_file.html"-->

    And unlike javascript, you don't have to worry about what will happen if the visitor has JS turned off.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    But to use SSI, your server has to support it, right? That's a limitation of it's own.

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    What are the pors and cons of SSI versus Javascript includes? Are there any good SSI tutorials or references that cover more on SSI?

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I think that's something you need to research a bit if you don't yet understand the difference. There are a lot of posts here regarding this subject, not to mention google.

    If your server supports server-side includes, you can simply include another HTML file by using the syntax above (assuming you have named your page with an ".shtml" extension).

    External javascripts are a different beast, as you will have to include them on the page like so:

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

    And then reference them as you would a javascript that was typed into the source code.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SSI is better than javascript includes though - since if your server supports SSI, the HTML will always be included.

    Javascript includes assume that the client has javascript enabled.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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