Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
173
rated 0 times [  175] [ 2]  / answers: 1 / hits: 17464  / 13 Years ago, thu, june 9, 2011, 12:00:00

Problem: I am creating an album.So on every press of



time NEXT button I am loading new Images. What I want to achieve is, I want to switch from old image to new image only once the new images has been downloaded fully from server.





Actually I dont want to show partial images while loading.


Is there any solution?



PS SIMILAR QUESTION but this is for Iphone. I need for browser?


More From » image

 Answers
37

Just make a new image via javascript, and only show the image after the onload has fired. This will make sure you don't see any partial rendering of the image.



Live Demo



    var curImg = new Image();

curImg.src = url to your image;
curImg.onload = function(){
// do whatever here, add it to the background, append the image ect.
imgHolder.appendChild(curImg);
}

[#91788] Wednesday, June 8, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jamaal

Total Points: 515
Total Questions: 102
Total Answers: 107

Location: France
Member since Thu, May 6, 2021
3 Years ago
;