Uncle Jim's JavaScript Examples

INSTRUCTIONS FOR USING SCRIPTS ON THIS SITE

I receive a lot of questions asking how to download and use the scripts on this site. While some script sites place detailed instructions on every page, I believe it is simpler to explain how to use these scripts on one page.

There are three basic areas where you should place the script code, depending upon how the code was written and what functions the script has:
Most scripts are found between the HEAD tags near the top of the page code. These will usually have some code either within the BODY section or within the BODY tag itself that calls the script funtions. Code found within the BODY tag will normally look something like onLoad="runscript()". All script codes will be placed inside SCRIPT tags.
Some scripts are used within the body section of the page code.
Some scripts are external, (found in a separate file), and are called from the page with a link.

The first thing to do is to view the source code of the page that has the script on it. This is where you will find all of the information you need. To view the source of this page, click here.

WHAT DO I DO NOW?

Looking in all of the areas of the page code noted above, you will need to copy the scripts and paste them into a text editor, such as NotePad. You should look at the entire page code as some scripts may have more than one function.

If external scripts are used, you will need to download the scripts from the source host. For example, if you see link rel=scriptname.js" on the source page, you can simply replace the name of the script page with scriptname.js in the address bar at the end of the URL address on the source page. A window will pop up asking you if you want to save or open the file. Save the file to your hard drive. This will be the external script you will need.

The script codes should be placed inside your own page code in the same area as they appeared on the original script example page.

SCRIPTS USING IMAGES

If the script you are copying uses images, you will also need to either download the image from the source page or create your own images, making sure you give them the same name. Some images are copyrighted and should only be used if permission is given from the owner. Most people do not mind if you use their script codes and images as long as they receive the proper credit that is due them. Never claim anything to be yours if you did not create it.

DIRECTORY STRUCTURE

This is probably the most common error when using scripts and images. Any script or image that is called for in the code must be in the same directory that it is called from. For example, if the script calls for an image named box.jpg in a directory called images, the code will look like img src="images/box.jpg". In order for that image to be displayed, the image file will need to be in a directory called images. Keep this in mind when using script codes from someone else's page.
This also applies to external scripts that may be placed in separate directories.

MODIFYING THE SCRIPT

Most all scripts have links and targets to pages on the site it originally came from. You will need to check the script and change these links to fit your own web site.

EXAMPLES

In order to give you an example, I have placed the Side Floating Menu on this page, (look at the bottom, right corner of the page).

This script has three parts to it:
The main script can be found in HEAD section of the source code. Simply copy everything between the SCRIPT tags, (including the tags), and paste into a text editor.
This script requires several onload events which can be found within the BODY tag.
This script also uses tables that change functions with mouseover events. These tables can be found directly underneath the BODY tag and between the DIV tags.

IT DIDN'T WORK, HUH?

Make sure you checked all areas of the original source page and retrieved all necessary functions and event codes needed. If this is the case, the next step is to take the entire contents of the original source page and copy it to a text editor. Remove any unnecessary text and try it out that way.

Though you may see blank areas where images should be displayed, the code should work properly. If not, you will probably need to seek the advise of a JavaScript expert to look over your source code to determine where the errors are at.

If the script works, then simply replace the surrounding information with that of your own. Make sure you only replace a little at a time, in case the script stops functioning properly, you will know where the error lies.

IN CONCLUSION . . . . .

Though you may initially have difficulties in getting some scripts to work properly, don't give up!. This is a great way to learn how javascripting works. I would venture to say that over 90% of the javascript experts today started learning this way. This includes yours truly.

HOW DO I GET HELP?

If you get stuck and simply can't get it to work, send me an email. I will attempt to find out what went wrong and show you what you need to do to correct it. Please adhere to the following when contacting me:
I only support those scripts that are currently found on my site. Please do not ask for help with someone else's script. They would be the best contact as they apparently got it to work.

Remember that most scripts are not compatable with both Netscape and Internet Explorer browsers. Usually, if they work in one, they don't work in the other. Every script on this site is compatable with the Internet Explorer browser, version 5.5 and above. You should check the script in both browser versions to ensure compatability.

When asking for help, please include the full address of the page where you found the script on my site. I have over 450 scripts on my site, and several scripts for each category.

Also, include the full address of the page on your site that contains the script you are having problems with. This way, I can compare the two and find the problem more easily, thereby fixing your problem quicker.

If you are having general problems or have general questions about javascripts and how they work, you may contact me at this address. This site consists of registered experts from around the world who volunteer to help those in need of assistance.