I'm not sure about your other post, could you link to it? If you mean Vic's code, it doesn't look like he included a preload/load check option, but you better ask him to be certain.
Anyways, if there is no option like that, instead of starting the slideshow right away, you could have a front end something like - say all the images in the slideshow are in a div with an id of slideshow, or you can collect them some other way. You run through them in a loop loading them, once they all either load or fail (error), you can then start the show.
I see his code can have markup like:
Code:
<div id="tst1" class="slideshow">
<img class="img" alt="Egypt" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" />
<div class="panel" ><a href="#">Panel 1</a></div>
<img class="img" alt="Egypt" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" />
<div class="panel" style="background-Color:red;">Panel 2</div>
<img class="img" alt="Egypt" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt7.jpg" />
<div class="panel" style="background-Color:green;" >Panel 3</div>
<img class="img" alt="Egypt" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt8.jpg" />
<div class="panel" style="background-Color:green;" >Panel 4</div> . . .
So for that particular show, those are the images. After the browser has parsed the page, you can check on things by doing:
Code:
<script type="text/javascript">
(function(){
var ims = document.getElementById('tst1').getElementsByTagName('img'), count = ims.length;
for(var i = 0; i < ims.length; ++i){
(function(s){
var im = new Image();
im.onload = im.onerror = function(){
if(!--count){
// run the init code for the 'tst1' slideshow here
}
};
im.src = s;
})(ims[i].src);
}
})();
</script>
That's assuming the init for the slideshow does no document.write business. It doesn't look like it does. I'd suggest putting that script right before the closing </body> tag. I'm not all that familiar with Vic's script though, there could be problems. Perhaps Vic could weigh in.
Bookmarks