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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
marcelcolt
Forum Newbie
Posts: 22
Joined: Tue Mar 02, 2010 5:56 am

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

Post 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!
User avatar
spedula
Forum Commoner
Posts: 81
Joined: Mon Mar 29, 2010 5:24 pm

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

Post by spedula »

You're kind of missing some valuable info there.

Like the part where you declare the alightBoxImage variable.
marcelcolt
Forum Newbie
Posts: 22
Joined: Tue Mar 02, 2010 5:56 am

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

Post 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?
marcelcolt
Forum Newbie
Posts: 22
Joined: Tue Mar 02, 2010 5:56 am

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

Post 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!
Post Reply