Site hosted by Angelfire.com: Build your free website today!
Script for Each Page
Enter the one of the following Code Objects on each page that requires the Javascript. If you have a title bar on each page, consider grouping script and title together.  It does not matter where physically you place the code object on your workpage. However after you place it, make sure you send it to the back -- use the 'To Back' button on the bottom toolbar. This ensures that the code object is at the top of the html page when you publish it.

This means that it will load sooner and will be available should your viewer be impatient (aren't we all?) and click on something that requires Javascript before the page is fully loaded. It is especially important when you have other code that uses the code in the include file and which runs while the the page is loading. There is an example of this on the in-page slideshows page.

Bruceee's Sandpit
Web Design with SiteSpinner
Javascript Include Files

If you have some Javascript you want to include on several pages, it makes sense keep it in a separate file. Your viewer has to download it only once, and thereafter his or her browser will get the file from its cache. This means that, after the first, your pages will download slightly faster -- there are no repeated downloads of the same code.

To include a separate Javascript file with your SiteSpinner project do this:
  • put  your common Javascript functions in a file with a .js extension
  • add a small script to each page of your project to include this .js file

The .js Include File
I've called my file 'common.js', but you can use any name you like. Remember that Javascript is case sensitive and 'common.js' is not the same as 'Common.js'.


The contents of the .js file is just the code for the functions you want - you don't have to repeat the <SCRIPT> tags. For example a complete common.js file for just a popup function is below. Don't read too much into the code, it is obsolete, -- I show it here just to illustrate the general format.
home
home
home
function popup(aFileName) {
day = new Date();
id = day.getTime();
aFileName = 'images/' + aFileName;
aFileName +='.jpg';
eval("page" + id + " = window.open(aFileName, '" + id + "', 'toolbar=    0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=660,height=506');");
return false;
}
<SCRIPT LANGUAGE=JAVASCRIPT SRC="common.js">
</SCRIPT>
My current common.js is in your browser cache now if you know how to get at it there. Or you can download the file here: common.js. I suggest you save it to disk, then view it with notepad or any other text editor. Don't try to view it or run it - nothing will seem to happen.

One day I'll get really clever and display the file directly here...

code
code
code
Add code to your pages
The above script assumes that you have called your file 'common.js' and that it is in the same folder as your .html files. Or, instead, do something like this:
<SCRIPT LANGUAGE=JAVASCRIPT SRC="code/common.js">
</SCRIPT>
The above script assumes that you have called your file 'common.js' and that it is in a folder called 'code'. This is a SiteSpinner default. The 'code' folder is in your root folder -- i.e. the same folder where your .html files live.