Login for Software or Support

CoffeeCup - HTML Editor, Flash & Web Design Software

Over 46,737,888 Downloads in 87 Countries

Tell a Friend About Our Cool Software

CoffeeCup Free DHTML Menu Builder Help Center

Sign In For Priority Support Forgot yours ?
More Free DHTML Menu Builder Help: Other Resources: Contact CoffeeCup:

Send Snail Mail:
CoffeeCup Software
165 Courtland Street
Suite A, Box 312
Atlanta, GA 30303

Give us a call:
Toll Free: 866.734.HTML (4865)
Sales Hotline: 678.495.3480
Fax: 678.495.3481

Using the DHTML Menu without all the code in your page.

Instead of pasting the source code for your menu on each page, you can link to a single external JS file from the page. Linking to external JS files is very similar to including an image in your Webpage. Consider the following image tag:


<img src="images/home.gif" WIDTH="100" HEIGHT="30">


The src="some image" tells the browser where to look for the image. The src= is looking for an image called "home.gif" in a folder called "images". This is known as a relative reference. The image is defined relative to the HTML page that contains the link. For example, if HTML the file is:

http://www.myweb.com/my_folder/index.html

then the browser will look for the file in

http://www.myweb.com/my_folder/images/home.gif

When you upload the file from your PC to your Web host, you must also upload the image file to the correct folder on your Web host.

In order to create the JS file, you will need to paste all the DHTML code that is inside the <SCRIPT> </SCRIPT> tags into a blank file HTML file and use Save As... to change the file extension to .js instead of .html. This means you do not want <SCRIPT LANGUAGE="javascript" SRC="javascript/dhtml_menu.js"></SCRIPT> in your JS file. You also do not want any other HTML, only the code between here <SCRIPT> and here </SCRIPT>.

External JS files work in the same way except the tag to link to them is slightly different. Take a look again:

<SCRIPT LANGUAGE="javascript" SRC="javascript/dhtml_menu.js"></SCRIPT>

The thing to note is there is an opening <SCRIPT> tag and a closing </SCRIPT> tag. It is very important you do not miss the closing tag, as anything between the <SCRIPT> and </SCRIPT> tag will be ignored by the browser.

<SCRIPT LANGUAGE="javascript" SRC="javascript/dhtml_menu.js"> This is ignored </SCRIPT>
This is why the closing </SCRIPT> tag is important. If you forget it, you could end up with nothing at all appearing in your page. In the above link there is LANGUAGE="javascript", which tells the browser to interpret the text in the file as JavaScript functions (as opposed to, say, VBScript). You do not have to use the name JavaScript for the folder. For example, <SCRIPT LANGUAGE="javascript" SRC="my_scripts/dhtml_menu.js"></SCRIPT> will look for the file "dhtml_menu.js" in the folder "my_scripts". Again the references are relative, so if your page that contains the link is at
http://www.myweb.com/my_folder/index.html
Then the browser will look for the file in
http://www.myweb.com/my_folder/my_scripts/dhtml_menu.js
Just like for images, when you upload a file from your PC to your Web host, you must upload the JS file to the correct folder as well.
Was this article helpful?

Free DHTML Menu Builder Help Index | Free DHTML Menu Builder Homepage

Download Our Software:

... and don't forget about our Free Software

CoffeeCup Home Page | Software | Copyright & Legal | Site Map | © 1996 - 2008 CoffeeCup Software, Inc.