Propeller
Propeller

Reputation: 2533

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?

Upvotes: 8

Views: 23616

Answers (4)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100195


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


Upvotes: 15

Gowri
Gowri

Reputation: 16845

Using javascript

   window.onload = function () { alert("loaded"); }

Upvotes: 0

Kristoffer Svanmark
Kristoffer Svanmark

Reputation: 778

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/

Upvotes: 5

Related Questions