Вопрос

Nowadays it is very common that people add a preloader to images. It helps in rendering the website even if all images are not loaded. My problem here is, when preloader is called, it doesn't check for any cached image. it always load the images from the server. Do you have any idea to check for chached image before calling image preloader? my preloader function is right below.

    $(function(){
$("#container").preloader();
});

it loads all the images inside the main div.

Это было полезно?

Решение

You want to know if a image is loaded right?

$('#image').onload(function(){alert('Fires when image is loaded');});

or

if(document.getElementById('image').complete){alert('Image is loaded');}

Thats how you can check if a image is loaded or not.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top