Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:55:47+00:00 2026-05-30T06:55:47+00:00

I have been using the following preload script to load all the images and

  • 0

I have been using the following preload script to load all the images and then switch two divs display settings to prevent the user from seeing the site “put together”. The problem is, of course, IE 8 and down refuse to switch. I have looked into several preloader issues and bugs like this and they all reference caching, but I have yet to find an actual fix… Any help will be greatly appreciated. Here is the code:

The extension:

(function($) {
var imgList = [];
$.extend({
    preload: function(imgArr, option) {
        var setting = $.extend({
            init: function(loaded, total) {},
            loaded: function(img, loaded, total) {},
            loaded_all: function(loaded, total) {}
        }, option);
        var total = imgArr.length;
        var loaded = 0;

        setting.init(0, total);
        for(var i in imgArr) {
            imgList.push($("<img />")
                .attr("src", imgArr[i])
                .load(function() {
                    loaded++;
                    setting.loaded(this, loaded, total);
                    if(loaded == total) {
                        setting.loaded_all(loaded, total);
                    }
                })
            );
        }

    }
});
})(jQuery);

The code to call it:

$(function() {
<? if ($dir = opendir('images')) {
        $images = array();
        while (false !== ($file = readdir($dir))) {
            if ($file != "." && $file != "..") {
                $images[] = $file; 
            }
        }
        closedir($dir);
        foreach($images as $image) {
            if(stristr($image, '.')) 
            $preload .= "'images/".$image."',";
        }
        $preload = substr($preload, 0, -1);
    }?>

    $.preload([<?=$preload?>], 
    {
        loaded_all: function(loaded, total) {
            $('#main_loading').css('display', 'none');
            $('#container').css('display', 'block');
        }
    });

});

I forget where I originally found this code, but have modified it a little to meet my needs. Our dev site where this can be seen is: http://www.branninggroup.com/backbeat/media_player/

I put in a temporary fix so it partially works right now in IE by forcing a 10 second wait before displaying it, but would obviously rather be able to know when the images have all loaded to display the page…. any tips/advice would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:55:48+00:00Added an answer on May 30, 2026 at 6:55 am

    That plugin is doing things wrong, one of which is related to an issue with IE and the load event.

    You need to define the load event, and then set the src property/attribute.

    Try replacing it with…

    (function($) {
    var imgList = [];
    $.extend({
        preload: function(imgArr, option) {
            var setting = $.extend({
                init: function(loaded, total) {},
                loaded: function(img, loaded, total) {},
                loaded_all: function(loaded, total) {}
            }, option);
            var total = imgArr.length;
            var loaded = 0;
    
            setting.init(0, total);
            for (var i = 0; i < total; i++) {
                imgList.push($("<img />")
                    .load(function() {
                        loaded++;
                        setting.loaded(this, loaded, total);
                        if(loaded == total) {
                            setting.loaded_all(loaded, total);
                        }
                    })
                    .attr("src", imgArr[i]);
    
                );
            }
    
        }
    });
    })(jQuery);
    

    I also changed the for (in) loop to a normal for loop. You don’t want to dredge up the prototype chain. You could also use $.each().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I have been using the following script for over a year now to
We have been using the following js/regex to find and replace all non-alphanumeric characters
I have been using the following regex to replace all punctuation in a string:
I have been using following function to display the file size in bytes in
I have been using the following code for loading JQuery in all of my
I have been using the following CSS to apply an effect at the bottom
I having trouble in dividing the HTML frames. I have been using the following
I have been following the following post on using multiple ItemTemplates in a ListView
I have been using Castle MonoRail for the last two years, but in a
I have been using the following command to open another MDB Access file via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.