views:

249

answers:

3

Hi, I have a Firefox 3.6.2 problem (3.5.x works just fine).

This is the code:

...
var newImage = new Image();
newImage.onload=function() {swapMapImg(newImage);};
newImage.src = newBackground;
...

function swapMapImg(newImage) {
    alert('bingo');
}

Firefox 3.6.2 no longer fires off my onload event, any ideas?

+1  A: 

I would personally start using jQuery if you can and use their onload functions. It should make life a LOT easier for you as someone else is maintaining and testing the code

Chris
A good suggestion.
Cheesle
A: 

I'm using Firefox 3.6.2 and your code works for me. Are you sure:

newImage.src = newBackground;

Is working? I mean, do you still see the image appear on the page? Because if the link's broken, onload isn't going to happen.

Matt Blaine
Thanks, pointed me in the right direction!
Cheesle
A: 

Turns out the following code:

var currentBackground = tableElem.style.backgroundImage;

returns two different strings in 3.5.x and 3.6.x as shown below:

3.5.x --> url(http://localhost:8080/WellSeismicMap/......);

3.6.x --> url("http://localhost:8080/WellSeismicMap/......");

notice the quotation mark in char position 4 in the 3.6.x version well this was throwing my substr function out and generating an invalid url.

Thanks for your help anyway chaps!

Cheesle