You're right about the imagefree stylesheet trying to load, the hack
helps here! You can set its initial value to 'On' ;)

There is a flash effect if you then switch between images on & off.
(Not likely to happen in production, though far from ideal of course).

I absolutley couldn't get this to work, using a proper returned
variable. I don't know why this is; it's currently the bane of my
life. Am reading more about jQuery callbacks & chaining, as I must be
missing something ....

If anybody feels kind enough to fix this solution so it works withut
hacks, PLEASE post it!!

Cheers :)
Cherry.

On Feb 16, 2:04 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote:
>
> The problem here is your .load callback will get called at some point in the
> future, when the image finishes loading. However, the next line will get
> executed immediately, without waiting for that. While this may work in some
> cases (perhaps your tests), it may not if the image is too large or if the
> server is slow in responding, for example. So, I don't think this is a good
> test.
>
> > (hack:  there is a hidden paragraph to hold the 'variable')
>
> A simple variable here works just as well:
>
> var imgOn = false;
>
> $('<img src="' + '/images/bgimage.jpg' + '#' + Math.random() + '"/>'
> ).load(function() {
>   $('#noimages').attr("href", '/styles/gotimages.css');
>   imgOn = true;
>
> });
>
> alert(imgOn);
>
> But you have the same problem as above: your alert could very well fire
> before the image is loaded, and the callback fired.
>
> - Richard

Reply via email to