Submit Your Article Forum Rules

Results 1 to 8 of 8

Thread: How Do I: JAVA Script Menu as an Include file?

  1. #1
    Junior Member
    Join Date
    Sep 2003
    Posts
    4

    How Do I: JAVA Script Menu as an Include file?

    Hi All,

    One problem I have been having is to create some type of an "include" string to pass in our JAVA menu into our web pages. At present, I have had to copy & paste the entire JAVA menu script into each and every web page as we wish to include the JAVA menu system on all pages. Needless to say, this is a real pain every time a change is required in the menu system.

    Have been working on creating some type of include string for each page which will load the JAVA menu system from an external file. To date, I have not been successful and find I have to ask for help.

    Does anyone know how to accomplish this?

    Respectfully,
    Art Freeman

    Really would like to thank anyone who would be willing to lend a helping hand.

  2. #2
    Senior Member Corey Bryant's Avatar
    Join Date
    Nov 2003
    Location
    Castle Pines North, CO
    Posts
    494
    Is it Java or javascript?

  3. #3
    Junior Member
    Join Date
    Sep 2003
    Posts
    4
    Hi Corey,

    Sorry for the confusion, our menu is javascript.

    Art

  4. #4
    Senior Member Corey Bryant's Avatar
    Join Date
    Nov 2003
    Location
    Castle Pines North, CO
    Posts
    494
    No worries, I just wanted to verify.

    Well you would save your javascript - everything between the script tags (not not the script tags) in a JS file. You can use Notepad to do this if your editor will not allow you to save as. And then you would just insert it where the javascript was supposed to be:
    <script type='text/javascript' src='javascripts/menu.js'>

  5. #5
    Junior Member
    Join Date
    Sep 2003
    Posts
    4
    Hi Corey,

    Well, gave it a try and came up with no menu loaded. Just did a copy & paste of your tag as noted to make sure not to have made a typo in the syntax.

    In the "menu.js" file, I tried it both with and without the opening & closing script tags. This is the problem I have been having. Am sure it can be done, it's just a case of getting the correct syntax.

    Art Freeman

  6. #6
    Senior Member Corey Bryant's Avatar
    Join Date
    Nov 2003
    Location
    Castle Pines North, CO
    Posts
    494
    Just to make sure - what did you name your JS file & where did you place it?

  7. #7
    Senior Member Narasinha's Avatar
    Join Date
    Aug 2003
    Posts
    230

    External JavaScript files

    I did notice that in the JavaScript code for the menu there were a few HTML comment tags within the code. When you copy the code out to the file menu.js remember to take these out. Also, remove the <script> and </script> from the top and bottom of the file. Replace this section of the HTML page with reference to the file so that your page's HTML has this section where that code used to be:
    Code:
    <link rel="StyleSheet" href="ChMenu00.css" type="text/css">
    
    <script type="text/javascript" src="menu.js"></script>
    I did this with a local copy of your page and it seemed to work out okay. The script section in the page where it computes and prints the current date can be left as it is. For more exact reference, the section of the HTML page that you want to take out to place into the menu.js file goes from line 17 to line 261. The menu.js file comes out to about 10k in size, so if the browser caches this file (as it should) it will reduce your bandwidth consumption and your page should load a bit faster.
    - [url=http://unrelated.dexterityunlimited.com/Relatively Unrelated[/url]

  8. #8
    Junior Member
    Join Date
    Sep 2003
    Posts
    4
    Hello Ernest,

    BINGO!!!!!!!!

    Worked like a charm. I knew it was a syntax problem, just couldn't seem to get the correct syntax to make it work. Would really like to thank you for your assistance as this will save me a tremendous amount of time down the road.

    Respectfully,
    Art Freeman

Similar Threads

  1. Java script dropdown menu compatibility
    By Milo in forum Web Programming Discussion Forum
    Replies: 3
    Last Post: 12-19-2004, 08:03 PM
  2. Java Script Menu NavBar in HTML/CSS...!
    By dwjonasen in forum Graphics & Design Discussion Forum
    Replies: 2
    Last Post: 12-19-2004, 07:12 PM
  3. aspx include file
    By SusieG in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 06-28-2004, 02:37 AM
  4. aspx file include in CF
    By SusieG in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 11-20-2003, 01:16 AM
  5. DHTML menu auto include on all pgs
    By RareBreed in forum Graphics & Design Discussion Forum
    Replies: 1
    Last Post: 10-25-2003, 05:21 PM

Posting Permissions

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