View Full Version : Outside Script File

02-11-2008, 02:42 AM
1) Script Title: Image with Description Tooltip

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/imagetooltip.htm#

3) Describe problem: Is there a way to put this script (the part that goes in the Head section) in a separate file that can be referenced on a html page and work similar to a css file. I tried with my limited knowledge and failed to get it to work.
Any help is greatly appreciated.

02-11-2008, 02:50 AM
1. Change the script tag by adding src="relativelocation/yourfile.js" to the end.
2. Remove everything, except the copyright notice which is required, from between the script tags and save it into that file.
That's all.

02-11-2008, 04:20 PM
Sorry, but you lost me. Please keep in mind I am very new at this. Can you be more specific.

02-11-2008, 04:30 PM
That wasn't quite correct anyway, the copyright notice needs to remain on the page. What djr33 says would work though. Try this more detailed explanation that also includes instructions for the proper handling of the copyright notice:

Use a text editor to save the script, call it 'file_name.js' where 'file_name' can be any valid file name of your choosing. Substitute the name of your external .js file for some.js in the below:

<script src="some.js" type="text/javascript"></script>

Common problems arise when:

1 ) The script file is not in the directory specified. In the above example it must be in the same directory as the page(s) that use it. Below, it can be in the scripts directory off of the root of a domain:

<script src="http://www.somedomain.com/scripts/some.js" type="text/javascript"></script>

2 ) Opening, closing and/or 'hiding' tags are left in the external file. This means that you must strip:
</script>and any of their many variations from the beginning and end of the external file.

3 ) The external call (<script src="some.js" type="text/javascript"></script>) is not inserted into the page at the correct spot. The external call must be inserted at the same place on the page where the script was/would have been.

4 ) Paths to other files (if) used by the script are no longer valid due to its location. This is only a problem if the external script is kept in a different directory than the page it was working on when it was an internal script. To correct this, use absolute paths inside the script. Absolute path examples:



5 ) Inappropriately combining two or more scripts into one external file. Usually external scripts can be combined if one knows enough about scripting to do so properly. Even then it is possible to overlook something.

A rule of thumb when testing is, if it won't work on the page, it won't work as an external file either.

One other thing, if this is a DD script or any script that requires the credit remain for legal use, include the credit in the on page call, ex:

<script src="some.js" type="text/javascript">
* IFrame SSI script II- Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use

Make sure to retain all the 'decorations', as these include begin and end javascript comment delimiters, without which the script won't function.

There is also info here:


02-11-2008, 07:05 PM
Thanks very much. I will try it and let you know.

02-11-2008, 07:18 PM
I just tried it and it works like a charm. Thanks Again.