View Full Version : How Do I: JAVA Script Menu as an Include file?
sitehost
12-02-2003, 03:35 AM
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.
Corey Bryant
12-02-2003, 07:56 AM
Is it Java or javascript?
sitehost
12-02-2003, 09:10 AM
Hi Corey,
Sorry for the confusion, our menu is javascript.
Art
Corey Bryant
12-02-2003, 09:24 AM
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'>
sitehost
12-02-2003, 09:58 AM
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
Corey Bryant
12-02-2003, 10:00 AM
Just to make sure - what did you name your JS file & where did you place it?
Narasinha
12-02-2003, 10:32 AM
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:
<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.
sitehost
12-02-2003, 11:02 AM
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