Problem with fader/fadeshow (preloading)

Hi :slight_smile:

I’ve got this fadeshow and I’m trying to delay starting time of it.

I added this code to the script, to the very end of the script specifically to this “fadeshow.prototype.startit=function(){” :

if (loaded) { 
this.populateslide(crossobj, this.curimageindex)

So the script will be populated with the images when they are loaded,
it seems to delay the loading of the slideshow, for some 4 seconds.
But I can’t figure it out, when I set the speed of the download to lower, it still starts after some time, but not with pictures loaded, but still loading.
That shows me it isn’t working, but why the delay then? And why isn’t it showing the alert message?
I’ve tried with setTimeout, but it doesn’t seem to even consider the milliseconds I feed it. Sometimes it gives me crossobj isn’t defined

I tried to look a bit deeper, but that script is really a mess - no formatting, missing braces etc…

Anyway, you need to do whatever it is you do to initialize the script, only after the images have loaded. It looks like you kinda intended to do that in your startit() method when you check for the loaded boolean variable, but, you only call startit() once, and since you call the method right away, it’s pretty much guaranteed that loaded is false, making it useless.

Maybe your function where you set the loaded variable to true, would be better if you just got rid of the boolean variable altogether, and just “started the slideshow” right then and there.

I still think it would have been easier to do this logic outside of that script, and just modify the script to not use document.write.

I tried adding that code to the countLoadedImages


It doesn’t work, even if I call new fadeshow from console, it doesn’t display anything. I think it’s the order of commands what is the problem here.

The code is a mess, I tried to reformat it, but somewhere in the middle of it I gave up.

I haven’t found a better slider either, I have but, their overall size (with frameworks) is much larger then needed.
I guess it’s unrational fear, since the frameworks could be already downloaded.

I’ve been coding and I changed write method to innerHTML.
It seems to be working now.

Now I’m trying to do the same thing with nivo slider.
It seems not to take array of javascript img objects but img tags.

Added this loop, it is supposed to add image elements to the slider div.
Somewhy it doesn’t do that, I’m not really familiar with JQuery, but this seems straightforward enough.

for (var i = 0, len = fadeimagesPHP.length; i < len; i++) {
$('#slider').append('<img src="'fadeimagesPHP[i][0]'" width="798" height="358" alt="" />');

It seems the problem has to do with JQuery line, when I remove it the loop starts working

You need to use the + operator to concatenate strings.

No change, no elements get added.