Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-02-2003, 04:35 AM
WebProWorld New Member
 

Join Date: Sep 2003
Location: USA
Posts: 7
sitehost RepRank 0
Default 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.
Reply With Quote
  #2 (permalink)  
Old 12-02-2003, 08:56 AM
WebProWorld Veteran
 

Join Date: Nov 2003
Location: Castle Rock, CO
Posts: 494
Corey Bryant RepRank 0
Default

Is it Java or javascript?
Reply With Quote
  #3 (permalink)  
Old 12-02-2003, 10:10 AM
WebProWorld New Member
 

Join Date: Sep 2003
Location: USA
Posts: 7
sitehost RepRank 0
Default

Hi Corey,

Sorry for the confusion, our menu is javascript.

Art
Reply With Quote
  #4 (permalink)  
Old 12-02-2003, 10:24 AM
WebProWorld Veteran
 

Join Date: Nov 2003
Location: Castle Rock, CO
Posts: 494
Corey Bryant RepRank 0
Default

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'>
Reply With Quote
  #5 (permalink)  
Old 12-02-2003, 10:58 AM
WebProWorld New Member
 

Join Date: Sep 2003
Location: USA
Posts: 7
sitehost RepRank 0
Default

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
Reply With Quote
  #6 (permalink)  
Old 12-02-2003, 11:00 AM
WebProWorld Veteran
 

Join Date: Nov 2003
Location: Castle Rock, CO
Posts: 494
Corey Bryant RepRank 0
Default

Just to make sure - what did you name your JS file & where did you place it?
Reply With Quote
  #7 (permalink)  
Old 12-02-2003, 11:32 AM
Narasinha's Avatar
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Urbana, Illinois, US
Posts: 306
Narasinha RepRank 1
Default 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.
Reply With Quote
  #8 (permalink)  
Old 12-02-2003, 12:02 PM
WebProWorld New Member
 

Join Date: Sep 2003
Location: USA
Posts: 7
sitehost RepRank 0
Default

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
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0