
Originally Posted by
humblenick
this seems to 'preload' the page itself but not the jpgs in it. Is it possible to get the spinner to stay on screen untill the page and all it's elements are loaded?
thnx
n
Not based on the above changes, no. Basically the "loading" text that gets shown will be erased as soon as Ajax has successfully fetched the requested page. Then it is overwritten by the new page contents; any images on this new page will take their time to load thereafter.
About the only way to ensure large images on an external page fetched via Ajax appears instantaneously is to preload them on the main page itself, before an Ajax request is even made to fetch the external page. The disadvantage of this is that the images will be preloaded even if the external page is never requested by the user. You can preload images by adding something like the below to the top of your main page:
Code:
<script type="text/javascript">
//populate below array with images to preload
var preimages=['image1.gif', 'dir/image2.gif', 'http://mysite.com/image3.gif']
for (var i=0; i<preimages.length; i++){
var preload=new Image()
preload.src=preimages[i]
}
</script>
Bookmarks