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

  • Home
  • SEARCH
  • 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 8371349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:08:27+00:00 2026-06-09T14:08:27+00:00

The ideas is to show the loading div while the image is loading and

  • 0

The ideas is to show the loading div while the image is loading and hide the div when finished. This code works on Chrome/firefox but not on IE. Any idea?

Html file

//image
<img src="image.php" class="loading">

//loading tag
<div id="loaddiv">
    <div id="loading_float"><img src="src/img/loading.gif">
    <br>Loading..
    </div>
</div>

JS file

var imgs_count=0, imgs_loaded=0;
$(function(){
$loading = $('.loading');
if($loading.size()>0){
    $loading.load(function(){
        $('#loaddiv').hide();
    });
}else{
    $('#loaddiv').show(); 
}
});
  • 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-06-09T14:08:28+00:00Added an answer on June 9, 2026 at 2:08 pm

    You cannot reliably use javascript to attach onload handlers to an image that is in the page’s HTML. That’s because the image may already be loaded before your javascript even gets a chance to run as the page DOM (and images referred to by it) starts loading before javascript has a chance to run and find those very DOM elements. This problem is worse in IE once the image is in the browser cache as IE loads the image pretty much instantaneously in that case.

    There are two possible work-arounds:

    1. Specify the onload handler in the actual HTML with the onload attribute.
    2. Don’t put the images in the HTML of the page. Use javascript to create them dynamically and assign onload handlers before the .src attribute is set on the image object so you are sure not to miss the onload event.
    3. When your javascript runs and before you install the load handler, check to see if the image is already loaded and act accordingly.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code $(#loading).ajaxStart(function() { alert(start); $(this).show(); }); in my mark-up <div style=text-align:center;><img id=loading src=../images/common/loading.gif
I have no idea why but the contentherewrap div does not show fully when
Custom map is broken on satellite view, does not show satellite imagery. Any ideas,
I'm trying to show a small loading image during a slow operation with jQuery
I got this image to tell people that some action is loading: http://problemio.com/img/ajax-loader.gif Then
I'm trying to get a page to show a loading... message while I create
I have a Div which I want to say Loading... while an AJAX request
Currently coding a mates portfolio and not to my surprise the code isn't loading
Any ideas how to fix this? UserService.UserServiceClient userServiceClient = new UserServiceClient(); userServiceClient.GetUsersCompleted += new
Any ideas given the code below why the highlight is being triggered to run

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.