Login for Software or Support

CoffeeCup - HTML Editor, Flash & Web Design Software

Over 45,135,556 Downloads in 87 Countries

Tell a Friend About Our Cool Software

CoffeeCup HTML Editor Help Center

Sign In For Priority Support Forgot yours ?
More The HTML Editor 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 web page. 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. This 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 Save As .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 LANGUAGE="javascript" SRC="javascript/dhtml_menu.js"> 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" This 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 also upload the ".js" file to the correct folder as well.

Was this article helpful?

The HTML Editor Help Index | The HTML Editor Homepage

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