That is an interesting idea.

Here's one possible way of handling it.  On document ready, set a timer for
a specified amount of time, that will search for each img on the page and
check to see if they are loaded and alter the url as needed.  I don't know
the best way to test for an image being loaded, perhaps by checking the
width attribute?

Possibly something like this:

$(document).ready(function()
        {
                setTimeout(RedirectImages,1000);
        });

function RedirectImages()
{
        $('img').each(function(i)
                {
                        var img = $(this);
                        var width = img.attr('width');
                        if (!width)
                        {
                                var newsrc = 'whatever';
                                img.attr('src',newsrc);
                        }
                });
}

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of cfdvlpr
Sent: Tuesday, June 12, 2007 1:24 PM
To: jQuery (English)
Subject: [jQuery] Can Jquery be used to provide an image backup system?


What I'd like to do is host my images remotely, but only if the remote
host is able to return my images in a short amount of time.  Can
jQuery be used to start a timer when the page is first hit and if
certain images are not loaded in X amount of seconds, then use a
different url for the images?  If so, can anyone help me get started
coding this?


Reply via email to