1

I am using

if (document.getElementById('<%= MainImg.ClientID %>').complete) {
  hideLoadDiv();
}

to hide a div which indicates the image is not loaded yet,

but it hides before the image has finished loading and is shown, while the browser is giving me a message that the page is still transferring data from the server :S

Is there another function I can use to make sure that the image is fully loaded?

Gergely Fehérvári
  • 7,811
  • 6
  • 47
  • 74
Miroo
  • 795
  • 3
  • 13
  • 35
  • 3
    possible duplicate of [Javascript callback for knowing when an image is loading](http://stackoverflow.com/questions/280049/javascript-callback-for-knowing-when-an-image-is-loading) – Felix Kling Feb 06 '11 at 11:45

3 Answers3

1

You can use the onload event on the image iteself:

<img src="foo.jpg" onload="hideLoadDiv();" />

Update: looks like your question is a dup

The Scrum Meister
  • 29,681
  • 8
  • 66
  • 64
1

javascript

img = new Image();
img.src = "foo.bar";
img.onload = function() {stuff();};
Gergely Fehérvári
  • 7,811
  • 6
  • 47
  • 74
0
img = new Image();
img.onload = function() {stuff();};
img.src = "foo.bar";

src should go last

Lev Savranskiy
  • 422
  • 2
  • 7
  • 19