Page 1 of 1

img.onload-function missfires (img.src undefined)

Posted: Tue Nov 30, 2010 4:34 pm
by marcelcolt
I have a img-preloader with an onload-function.
Only thing is, in IE it works great but in Firefox it doesn't.

As can be seen in the example below i have a dynamically generated image wich i need dimensions from.
As said in IE (from 6 to 8) no prob's, but testing in FF it fails.
Firebug keeps telling me 'alightBoxImage' is undefined.

I just can't figure out why!

Code: Select all

imgPreloader.onload = (function(){
    	alightBoxImage.src = imageArray[activeImage];
        resizeImageContainer(imgPreloader.width, imgPreloader.height);
	});
    imgPreloader.src = imageArray[activeImage];
Help...please!

Re: img.onload-function missfires (img.src undefined)

Posted: Thu Dec 02, 2010 7:15 pm
by spedula
You're kind of missing some valuable info there.

Like the part where you declare the alightBoxImage variable.

Re: img.onload-function missfires (img.src undefined)

Posted: Fri Dec 03, 2010 3:05 pm
by marcelcolt
Yeah about that...
It's a dynamically made HTML-image.
It's appended at the end of the page with jQuery's 'appendTo'.

There is actually no other declaration other then that.
IE has no problems with it, FF (no matter what version by the way) does.

I keep getting the "alightBoxImage not declared"-message.

Is that a FF-thing?

Re: img.onload-function missfires (img.src undefined)

Posted: Sat Dec 04, 2010 2:20 am
by marcelcolt
Nevermind...
I've solved the issue using jQuery!

Code: Select all

jQuery('#alightBoxImage').attr({src: imageArray[activeImage]});
Once again jQuery saves my behind!

Tnx anyway!