Forum Moderators: open

Message Too Old, No Replies

Javascript Preload Images only works on Mac

Javascript Preload Images only works on Mac not PC

         

matt9807

7:40 pm on Apr 6, 2008 (gmt 0)

10+ Year Member



I've made this script for preloading images for a small slideshow. It works great on Safari and FF for Mac, but doesn't work at all on IE or FF for PC. Does anybody have any ideas as to why it isn't working and what I can do to solve the problem?

Here is the preload portion of the script:

imgSeries = new Array();
curImg = '';

// Adjust No. of Images
imgQuant = 94;

function loadkill() {
document.getElementById('loadingtxt').style.display = "none";
document.getElementById('imgone').src = imgSeries[0];
document.getElementById('imgtwo').src = imgSeries[1];
}

for (i=0; i<=imgQuant; i++) {

if (i<10) {
i = '00' + i;
} else if (i>=10 && i<100) {
i = '0' + i;
}
curImg = 'images/img' + i + '.jpg';
imgSeries.push(curImg);
}

function preloadImgs() {
// Preload Images
for (i=0; i<=imgSeries.length; i++) {
preload_img_object = 'preload_img_object' + i;
preload_img_object = new Image();
preload_img_object.src = imgSeries[i];
}
}

daveVk

1:00 am on Apr 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



var i,s
for (i=0; i<=imgQuant; i++) {

if (i<10) {
s = '00' + i;
} else if (i>=10 && i<100) {
s = '0' + i;
} else s = i;
curImg = 'images/img' + s + '.jpg';
imgSeries.push(curImg);
}

Changing of loop control variable "i" is not a good idea

preload_img_object = 'preload_img_object' + i;
preload_img_object = new Image();

Use of first line ?

Welcome to the forum