Car Credit - Debt Consolidation - Mobile Phone - Cheap Loan - Personal Loans

PDA

View Full Version : Load image from another location if server is lagged


forumposters
Jun 13th 2007, 10:52 am
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?

krakjoe
Jun 13th 2007, 11:06 am
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

forumposters
Jun 14th 2007, 9:44 am
What about using .complete?

krakjoe
Jun 14th 2007, 10:08 am
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>