What I'd like to do is host my images remotely, but only if the remote host is able to load my images in a short amount of time. Can javascript be used to start a timer when the page is first hit and if certain images are not loaded in 5 seconds, then use a different url (at a different server) for the images? If so, can anyone help me get started coding this? Any other ideas on how to better code this task?
Not really, there are no events triggered when an image finished loading by default and so theres no way to tell when the user has all the data
good thinking it would seem that onload works however I dont have any ideas on how to make it wait and then swap the image over, if I get any I'll post em ..... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <img src="http://www.webreference.com/i.gif" id="img" /> <script language="javascript"> document.getElementById('img').onload=function() { alert( 'onload triggered' ); } </script> </body> </html> HTML: