This is great! Could you possibly show me an example of this online?

On Mar 7, 12:12 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> This may be out of left field from what you're asking but I wrote a script
> called "onImagesLoaded", with a tolerance setting.  I used this to fire the
> jquery.flash.js script only after most of the images had been downloaded.
>
> Some sites I've coded were overly image-heavy with the Flash at the top of
> the page, so it would tend to make an ugly user-experience.  If they're of
> any value to you, here they are:
>
> // Fire a specific event once all images are loaded.
> function onImagesLoaded(fn,tolerance)
> {
>   // Ensure we have a valid function.
>   if (!$.isFunction(fn)) return;
>
>   var images = $('img').filter(function(el,i) { return !this.complete; });
>
>   if (images.length)
>   {
>     window.$loadedImageCount = images.length;
>     window.$imagesLoadedTolerance = $.toInt(tolerance);
>     if (!window.$onImagesLoaded) window.$onImagesLoaded = [];
>     window.$onImagesLoaded.push(fn);
>     images.one('load',imageHasLoaded);
>   }
>   else
>     fn();
>
> }
>
> // Each time an image is loaded, check to see if we can fire the event.
> function imageHasLoaded(e)
> {
>   // Ensure we still have functions to execute.
>   if (!window.$onImagesLoaded) return;
>
>   // Reduce the number of images left.
>   try { window.$loadedImageCount--; } catch(ex) {}
>
>   // If we've reached 0 or the tolerance, fire the events.
>   if ((window.$loadedImageCount||0) <= (window.$imagesLoadedTolerance||0))
>   {
>     for (var i=0;i<window.$onImagesLoaded.length;i++)
>     {
>       if ($.isFunction(window.$onImagesLoaded[i]))
>         window.$onImagesLoaded[i]();
>     }
>     window.$onImagesLoaded = null;
>   }
>
> }
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> Behalf Of Karl Rudd
> Sent: Friday, March 07, 2008 4:31 AM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: How to know if the entire page has loaded, AFTER it
> has loaded? [advanced]
>
> Use the "good old" "load" event.
>
> $(window).load(function () {
>   // run code
> });
>
> ( fromhttp://docs.jquery.com/Events/load)
>
> Karl Rudd
>
> On Fri, Mar 7, 2008 at 11:10 PM, Iair Salem <[EMAIL PROTECTED]> wrote:
>
> >  Sorry about not being so clear: what I exactly want is to know if
> >  window has loaded. I need to be sure if all the IMAGES had been
> >  loaded, that's why jQuery.isReady is useless for me. jquery.isReady
> >  equals true when DOM is loaded, but not the images.
> >  I hope someone could help me.
> >  Iair Salem.
>
> >  PD: Please Google do something about the delay for a message to be
> >  seen and searchable on the group.
>
> >  On 7 mar, 09:11, Ariel Flesler <[EMAIL PROTECTED]> wrote:
> >  > As far as I know, document.ready will execute functions right away if
> >  > the dom is ready.
> >  > Also you can use: if( jQuery.isReady ).....
>
> >  > On 6 mar, 17:46,IairSalem<[EMAIL PROTECTED]> wrote:
>
> >  > > 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,
>
> >  > >IairSalem

Reply via email to