Rate this script:  I Love it  /   I Hate it

check if all the images have been loaded


Code



        // allImagesLoaded()
        // Checks if all the images are loaded in the document
        // It Does this by looping through all the images and checks the attribute .complete
        // If .complete is false then we set the return variable to 0
        function allImagesLoaded() {
       
                // return variable
                var imagesloaded = 1;
       
                // All images are saved in an array called document.images. Very usefull
                var images = document.images;
                // Loop through all the images
                for (var i = 0;i<images.length;i++)
                {
                        // If the image isnt loaded we set the return varible to 0
                        if(images[i].complete == false) {
                                imagesloaded = 0;
                        }
                }
       
                // This will return 0 if one or more images are not loaded and 1 if all images are loaded.
                return imagesloaded;
        }

 

 

 
check if all the images have been loaded scripts | check if all the images have been loaded snippet | check if all the images have been loaded example | check if all the images have been loaded tutorial | check if all the images have been loaded code