[Javascript] How to include multiple paths
Richard
nomorebull at charter.net
Thu Feb 10 02:24:44 CST 2005
Using the script below, I want to use more than one list and path as shown
here.
Where "planes" could also be like "fruit", "bugs", "homes" or whatever.
User clicks open a main menu, clicks a group, thumbnails are displayed below
the main image.
Main image is replaced with the appropriate image.
Clues appreciated.
// put images to preload in this array
var preload_list = new Array("pic101.jpg", "pic102.jpg", "pic103.jpg",
"pic104.jpg");
var path_to_images = "planes/";
// preload (change path to images if necessary)
if (document.images) {
var image_list = new Array();
for (var preload_counter=0; preload_counter<preload_list.length;
preload_counter++) {
image_list[preload_counter] = new Image();
image_list[preload_counter].src = path_to_images +
preload_list[preload_counter];
}
}
function swapImage(num) {
if (document.images) {
document.main.src = image_list[num].src;
}
}
More information about the Javascript
mailing list