Results 1 to 2 of 2

Thread: Variables and Firefox

  1. #1
    Join Date
    May 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Variables and Firefox

    I have a script that iterates through pictures when you hit a "Next" link; the HTML looks like this:

    HTML Code:
    <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:

    HTML Code:
    <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

  2. #2
    Join Date
    May 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default I got it

    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:

    Code:
    document.getElementById('background').style.background = "background-image: url('" + image.src + "')";
    when I needed to be doing this:

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •