Javascript (?) help - need to check connectivity

From: Dan (HERMAND) 3 Sep 2011 16:52
To: Peter (BOUGHTONP) 14 of 18
code:
function checkImageUrl()
{
 
$('#ImageTest')
  .error(function() {
  setTimeout("checkImageUrl()", 2000);
  })
 
  $('#ImageTest').load(function() {
  window.location.replace(redirectURL);
  });
 
  $('#ImageTest').attr("src", imageURL + "?=" + d.getTime());
 
}
 
checkImageUrl();


Trial and error, yay!
From: Dan (HERMAND) 3 Sep 2011 16:55
To: Dan (HERMAND) 15 of 18
Hmm, this does work but looking at it in FireBug, it appears to exponentially load images and I'm not really sure why :(
From: Dan (HERMAND) 3 Sep 2011 17:06
To: Dan (HERMAND) 16 of 18
Ah, every time the function is called I'm creating a new event handler. Moved them out of the function and I think I'm there.
From: Peter (BOUGHTONP) 3 Sep 2011 17:14
To: Dan (HERMAND) 17 of 18
Yay!

Course once you switch to IE7 you'll probably find some random annoying error cropping up just to be a pain. :(
From: Dan (HERMAND) 3 Sep 2011 17:24
To: Peter (BOUGHTONP) 18 of 18

You were right :D Just does nothing after the first event in IE, I guess changing the image url doesn't force a reload of the image.

 

I have, however, got it working by forcing a page refresh. I'll try and figure out how to get IE to reload the image because it's much cleaner, but at least I can make it work regardless.