[jQuery] How to know if the entire page has loaded, AFTER it has loaded? [advanced]

[jQuery] How to know if the entire page has loaded, AFTER it has loaded? [advanced]


Hello everyone, I have a problem
The basics:
$(document).ready(function(){alert("DOM Loaded")});
$(window).load(function(){alert("Full Page & Images Loaded")});
But, what happens if I do this?:
$(window).load(function(){
setTimeout("foo()", 2000);
);
function foo(){
$(window).load(function(){alert("this alert will never occur")}); /
*calling window load() after it has been called once results in
nothing happening....*/
}
This beaviour isn't the same as $(document).ready, because $
(document).ready is handled by jQuery, and jQuery sets jQuery.isReady
= true, and calls it inmediately.
Maybe I'm asking for the property jQuery.isPageLoaded which would tell
me if the entire page has loaded, also AFTER the page has loaded (for
example in a click event).
There is a dirty workaround:
var isPageLoaded = false;
$(window).load(
function(){
isPageLoaded=true;
}
);
This will workaround the problem and fix it partially (because in
theory this won't work when loading scripts dinamically)
If you have a better solution, please share it with the group.
Thank you,
Iair Salem