J
Julie
Hi,
I'm trying to change images on a website without reloading the whole
page and use the following code to preload the images:
var preloadFlag = false;
function preloadImages() {
if (document.images) {
pic_moon2_click = newImage("images/moonpic2.jpg");
pic_moon3_click = newImage("images/moonpic3.jpg");
pic_moon4_click = newImage("images/moonpic4.jpg");
one_click = newImage("images/1.gif");
two_click = newImage("images/2r.gif");
three_click = newImage("images/3r.gif");
flour_click = newImage("images/4r.gif");
two_caps_click = newImage("images/mooncaps2.gif");
three_caps_click = newImage("images/mooncaps3.gif");
four_caps_click = newImage("images/mooncaps4.gif");
preloadFlag = true;
}
}
to change the images I use this code:
function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments].src =
changeImages.arguments[i+1];
}
}
}
when I click on the field that should make the images change (images
in three places are supposed to change at the same time, including the
one I'm clicking) I hand over two variables for each imagefield, the
name of the image tag that I want to change and the source of the new
image, I separate each group of two variables by a comma.
On my mac and various other platforms it seems to work fine but on
certain computers with Windows XP (IE6), not on all, the new images
don't load, but after clicking the button the image td is empty. If I
right click into the td and click on "Load Image" the right image
loads.
I tried to look at the page locally and then it all works fine even on
XP. So I thought it must have something to do with preloading the
images.
After that I tried a different code that doesn't use a preload
function but for some reason that didn't work either.
I have no idea what else to try... maybe someone here can help me
I'm trying to change images on a website without reloading the whole
page and use the following code to preload the images:
var preloadFlag = false;
function preloadImages() {
if (document.images) {
pic_moon2_click = newImage("images/moonpic2.jpg");
pic_moon3_click = newImage("images/moonpic3.jpg");
pic_moon4_click = newImage("images/moonpic4.jpg");
one_click = newImage("images/1.gif");
two_click = newImage("images/2r.gif");
three_click = newImage("images/3r.gif");
flour_click = newImage("images/4r.gif");
two_caps_click = newImage("images/mooncaps2.gif");
three_caps_click = newImage("images/mooncaps3.gif");
four_caps_click = newImage("images/mooncaps4.gif");
preloadFlag = true;
}
}
to change the images I use this code:
function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments].src =
changeImages.arguments[i+1];
}
}
}
when I click on the field that should make the images change (images
in three places are supposed to change at the same time, including the
one I'm clicking) I hand over two variables for each imagefield, the
name of the image tag that I want to change and the source of the new
image, I separate each group of two variables by a comma.
On my mac and various other platforms it seems to work fine but on
certain computers with Windows XP (IE6), not on all, the new images
don't load, but after clicking the button the image td is empty. If I
right click into the td and click on "Load Image" the right image
loads.
I tried to look at the page locally and then it all works fine even on
XP. So I thought it must have something to do with preloading the
images.
After that I tried a different code that doesn't use a preload
function but for some reason that didn't work either.
I have no idea what else to try... maybe someone here can help me