PDA

View Full Version : Variables and Firefox



noob_developer
06-02-2008, 03:40 PM
I have a script that iterates through pictures when you hit a "Next" link; the HTML looks like this:


<a href = "javascript:next();" id = "next" onclick = "processClick(1, 1); return false;"><span>CSS2</span></a>

the second argument in the processClick function is the number for the next picture, so that number will change from 1 to 2 to 3, etc. My javaScript that does this looks soemthing like this:

next.onclick = function(){processClick(1, num); return false;};

My issue is that when I load the page in IE the script works fine but in Firefox it doesn't do the math correctly. Instead of replacing the num variable with a number when the onclick attribute is reset in the function it leaves the variable as is within the function call, so when I click to go to the next image that attribute gets set as:


<a href = "javascript:next();" id = "next" onclick = "processClick(1, num); return false;"><span>CSS2</span></a>

How do I get this to display correctly in both ff and IE? Thanks,

-S

noob_developer
06-02-2008, 05:52 PM
I figured it out and it had nothing to do with what I posted, so sorry if I lead anyone on a wild goose chase. In Firefox I was trying to load the background image like this:


document.getElementById('background').style.background = "background-image: url('" + image.src + "')";

when I needed to be doing this:


document.getElementById('background').style.backgroundImage = "url('" + image.src + "')";

-S