homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

checking preloads....
JS gurus welcome!

 9:24 am on Apr 25, 2003 (gmt 0)

A while back I stumbled across a bit of script that I could add to my preloader that would check and see if the images were actually preloading. It would pop-up an alert box when all of the preloading was finished. Being the clever person I am, I seem to have *cough* 'lost' that bit of script. I have searched high and low, but I have been unsuccessful at locating it on the web again.

It went something like this:

function preLoad() {

image01 = new Image();
image01.onload = loadCheck;
image01.src = "images/aticob.jpg";

image02 = new Image();
image02.onload = loadCheck;
image02.src = "images/primerb.jpg";

This bit of code is missing something though. Namely what to do with the loadcheck data, and popping up the alert box. I am a JS rookie at best, although like many, I can hack together what I need, but this is evading me. Can anyone help me out with this?



 1:22 pm on Apr 25, 2003 (gmt 0)

I guess you could make the function loadCheck count until it reaches the number of images you're preloading:

var count = 0;
function loadCheck() {
if(count == 5) {
alert("I'm ready!");
function preLoad() {
image01 = new Image();
image01.src = "images/aticob.jpg";
image01.onload = loadCheck();
// et cetera

Please note I haven't tested this...


 7:26 pm on Apr 25, 2003 (gmt 0)

That was it. I'll try it and go from there. Thanks, I just don't trust preloaders on there own when designing!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved