I have seen a lot of pre-loading scripts and none of them seem to help with my problem.
Let's say I have a list of images:
"image1.jpg "
"image2.jpg "
"image3.jpg "
And all the pictures hosted at both:
I would like to attempt to load pictures from:
and if they fail, get them from the mirror site.
It is acceptable that if one image cannot be found on the first location, to bypass it and get ALL the images from the second location.
Originally I had something like this:
[code=html]
<img src="http://mydomain.com/images/image1.jpg" onerror="this.s rc='http://mydomain2.com/images/image1.jpg'" />
[/code]
However, that seems to be a no-no for standards, not to mention causes an infinite loop if the image can also not be found at the second location.
It was recomended that I switch to useing javascript to pre-load the images, but I couldn't find anything in the DOM about detecting if there was an error loading or not.
Does anyone have any ideas for how to detect if the location given to .src can be found?
Let's say I have a list of images:
"image1.jpg "
"image2.jpg "
"image3.jpg "
And all the pictures hosted at both:
I would like to attempt to load pictures from:
and if they fail, get them from the mirror site.
It is acceptable that if one image cannot be found on the first location, to bypass it and get ALL the images from the second location.
Originally I had something like this:
[code=html]
<img src="http://mydomain.com/images/image1.jpg" onerror="this.s rc='http://mydomain2.com/images/image1.jpg'" />
[/code]
However, that seems to be a no-no for standards, not to mention causes an infinite loop if the image can also not be found at the second location.
It was recomended that I switch to useing javascript to pre-load the images, but I couldn't find anything in the DOM about detecting if there was an error loading or not.
Does anyone have any ideas for how to detect if the location given to .src can be found?
Comment