I'm having a site where, at the page load, I'm updating the src of an image using an Ajax call, and then using the response to set the new src attribute.
The problem is, the page finishes loading before my images have been updated (or fully loaded). This means the images first show up incorrectly for some milliseconds, before changing to their correct image after the src has been updated.
I'm triggering the image action on window.onload. I'm actually doing this now:
Expand|Select|Wrap|Line Numbers
- function init() {
- hideImages(); // hide all images on site
- checkImages(); // modifies the src of every image
- showImages(); // shows all the images again
- document.getElementById('main').style.display = "block"; // makes content visible since it's got display:none by default
- }
- window.onload = init;
Thanks!