Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if a page has fully rendered using jQuery?

When using $(document).ready(functioon(){alert("Loaded.")}); it pops up the alert box that says "Loaded." even before the page has fully loaded (in other words there're loading still going on like images).

Any thoughts?

like image 644
Propeller Avatar asked Mar 09 '12 08:03

Propeller


2 Answers


$(window).on('load', function() {
    //everything is loaded
});


like image 50
Sudhir Bastakoti Avatar answered Sep 17 '22 14:09

Sudhir Bastakoti


Try out .load() instead.

$(document).load(function () {
    alert('Loaded');
}

The load event is sent to an element when it and all sub-elements have been completely loaded. http://api.jquery.com/load-event/

like image 45
Kristoffer Svanmark Avatar answered Sep 16 '22 14:09

Kristoffer Svanmark