On 13 Feb, 15:56, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I've been trying to [1] get a named boolean out of this, which I can > later use for checks; [2] turn it into a reusable function - ideally, > both things together!
I think it is not easy as it seems, and I'll try to explain why :) you could put that code in a function, something like this: var checkImages = function(){ $('<img src="http://www.google.com/intl/en_ALL/images/logo.gif' + '#' + Math.random() + '"/>').load(function() { var ImagesAreLoaded = true; return ImagesAreLoaded; }); } and then do the check like this var images = checkImages(); the problem is that the variable ImagesAreLoaded, inside the function checkImages(), will not be initialized until the load() method has completed its task. so what you will get from the checkImages function is 'undefined'. and that doesn't help much. one thing I would suggest is that you put all the code that relies upon images being active on the user's browser inside that load()... but I fear this would slow down thing a lot. I'm not an expert around here, I'm just trying to understand how things work. I hope my explanation wasn't too wrong :)