Reputation: 805
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?
Upvotes: 1
Views: 2414
Reputation: 430
img = new Image(); img.onload = function() {stuff();}; img.src = "foo.bar";
src should go last
Upvotes: 0
Reputation: 7941
javascript
img = new Image();
img.src = "foo.bar";
img.onload = function() {stuff();};
Upvotes: 1
Reputation: 30111
You can use the onload event on the image iteself:
<img src="foo.jpg" onload="hideLoadDiv();" />
Update: looks like your question is a dup
Upvotes: 1