M
M
Maxim Vasiliev2012-01-25 08:45:51
JavaScript
Maxim Vasiliev, 2012-01-25 08:45:51

$(document).ready in google chrome?

In chrome (17-beta, 16-stable) the onload trigger fires before the images are loaded.

If an ajax request is called from this trigger and you want to show the user a loading indicator with an animated gif twist, he will not see it, because the gif has not yet been loaded at the time the request was sent.

How to be?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
K
Konstantin Kitmanov, 2012-01-25
@qmax

Encode gif in base-64 and use data:uri in CSS - duris.ru/faq/

V
Vitaly Zheltyakov, 2012-01-25
@VitaZheltyakov

Isn't it easier to make this gif immediately visible? The page is loading.

L
lashtal, 2012-01-25
@lashtal

It should fire before the images are loaded. Chrome has nothing to do with it, by the way.
For images there is imagesLoaded ( github.com/desandro/imagesloaded ) from under masonry.

F
Fr3nzy, 2012-01-25
@Fr3nzy

In Chrome and Safari, in such cases, you can also use $(window).load(), which "fires" only after loading any media content.

N
nikitammf, 2012-01-25
@nikitammf

the event fires correctly, you can write that all functions are called after the image is loaded

jQuery(function($){
    var loadingImage = new Image();
    loadingImage.onload = function(){
        loadingImage.onload = null;
        //основные функции
    };
    loadingImage.src = "image/loader.gif";
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question