Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery - can I detect once all content is loaded?

I have a page with a lot of ads being loaded in piece by piece.

I need to position an element relative to overall page height, which is changing during load, because of ads being added.

Question: Is there a jquery event or similar to detect, when all elements are loaded? I'm currently "waiting" with setTimeout, but this is far from nice.

An idle event would be nice, which fires once after pageload if no new http requests are made for xyz secs.

like image 391
frequent Avatar asked Sep 01 '25 16:09

frequent


1 Answers

You can use onload event which triggers when ALL elements eg DOM, images, frames and external resources have loaded into the page.

Vanilla JavaScript:

window.onload = function(){ ......... }

jQuery:

$(window).load(function() {.........});
  • window.onload: https://developer.mozilla.org/en/DOM/window.onload
  • $(window).load : http://api.jquery.com/load-event/
like image 115
Sarfraz Avatar answered Sep 04 '25 06:09

Sarfraz